diff options
| author | Adam Soltys <[email protected]> | 2026-08-17 22:32:03 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-08-17 22:32:03 -0700 |
| commit | f385ae87f7b65ef2e2cc7caaedc78170c6c99392 (patch) | |
| tree | 55d4601221946f36bf6c90889d45caa70ef365b6 /lib/nwc.ts | |
| parent | f242dd2b9376505e354b5f270c910e1fb0a173c4 (diff) | |
| download | coinos-server-f385ae87f7b65ef2e2cc7caaedc78170c6c99392.tar.gz coinos-server-f385ae87f7b65ef2e2cc7caaedc78170c6c99392.zip | |
nwc: reply UNAUTHORIZED on unknown connection instead of returning silently
A NIP-47 request whose pubkey/user no longer exists (deleted app or migrated
user) was silently dropped, leaving the client spinning. Send an UNAUTHORIZED
error reply so the client can surface it. Still not logged (not a server fault).
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Diffstat (limited to 'lib/nwc.ts')
| -rw-r--r-- | lib/nwc.ts | 15 |
1 files changed, 13 insertions, 2 deletions
@@ -309,8 +309,19 @@ export default () => { await reply({ result_type: method, ...result }); } } catch (e) { - // Stale client state (deleted app or migrated user) is not a server fault — don't log. - if (e.message === "pubkey not found" || e.message === "user not found") return; + // Stale client state (deleted app or migrated user) is not a server + // fault — don't log it, but DO answer: a NIP-47 UNAUTHORIZED reply + // lets the client surface an error instead of spinning forever on a + // connection this server no longer knows. + if (e.message === "pubkey not found" || e.message === "user not found") { + try { + await reply({ + result_type: method, + error: { code: "UNAUTHORIZED", message: "unknown connection" }, + }); + } catch (_) {} + return; + } err("problem with nwc", pubkey, method, e.message); // Still reply so the client isn't left hanging on the failure. try { |
