Skip to content

[BUG] NIP-43 join fails with SN_NOT_SERIALIZABLE in admit_user() #1074

Closed

Description

@jenslj

Describe the bug
I am running nostream 3.12.1 using the production Docker Compose deployment with PostgreSQL 15.
After enabling NIP-43, I created an invite using the nostream CLI and attempted to redeem it using a correctly signed NIP-43 kind 28934 join event.

To Reproduce
The relay receives and processes the join request, but admission fails with:
Unable to admit user.
Reason: select admit_user($1, $2) - SN_NOT_SERIALIZABLE

The log shows that the join event reaches the event handler correctly:
kind: 28934 pubkey: and execution reaches UserRepository.admitUser().

In /app/src/repositories/user-repository.js, admitUser() currently calls:
await client.raw(
'select admit_user(?, ?)',
[toBuffer(pubkey), admittedAt.toISOString()]
);

The PostgreSQL admit_user() function begins with:
PERFORM ASSERT_SERIALIZED();
and assert_serialized() contains:
IF (
select current_setting('transaction_isolation') <> 'serializable'
) THEN
RAISE EXCEPTION 'SN_NOT_SERIALIZABLE';
END IF;

The PostgreSQL instance reports:
SHOW default_transaction_isolation; as read committed

I don't see a transaction with SERIALIZABLE isolation being established around the admit_user() call in UserRepository.admitUser().

Expected behavior
A valid NIP-43 kind 28934 join request using a valid invite should admit the requesting pubkey.

Actual behaviour
The join request reaches admit_user(), but PostgreSQL intentionally aborts it with: SN_NOT_SERIALIZABLE because the transaction isolation level is read committed.

System (please complete the following information):

  • OS: Ubuntu 26.04.1 LTS
  • Deployment: Dockge / Docker Compose
  • nostream: 3.12.1
  • nostream image: ghcr.io/cameri/nostream:latest
  • nostream image ID: 4fed51a721a1
  • PostgreSQL: 15
  • PostgreSQL image: postgres:15
  • Redis: 7.0.5 Alpine 3.16
  • Redis image: redis:7.0.5-alpine3.16
  • NIP-43: enabled

Logs
{"level":50,"scope":"worker:user-repository","err":{
"type":"DatabaseError",
"message":"select admit_user($1, $2) - SN_NOT_SERIALIZABLE",
"severity":"ERROR",
"code":"P0001",
"where":"PL/pgSQL function assert_serialized() line 4 at RAISE\nSQL statement "SELECT ASSERT_SERIALIZED()"\nPL/pgSQL function admit_user(bytea,timestamp without time zone) line 3 at PERFORM"
},"msg":"Unable to admit user. Reason: select admit_user($1, $2) - SN_NOT_SERIALIZABLE"}

{"level":50,"scope":"worker:event-message-handler","err":{
"type":"DatabaseError",
"message":"select admit_user($1, $2) - SN_NOT_SERIALIZABLE",
"severity":"ERROR",
"code":"P0001"
},"msg":"error handling NIP-43 EVENT kind 28934: select admit_user($1, $2) - SN_NOT_SERIALIZABLE"}

Activity

  1. cameri commented on Nov 7, 2026

    @cameri
    Owner

    @jenslj Thanks for the bug report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions