Skip to content

Fix: handle ECONNRESET gracefully instead of crashing - #139

Merged
melvincarvalho merged 1 commit into
gh-pagesfrom
issue-138-econnreset
Feb 28, 2026
Merged

Fix: handle ECONNRESET gracefully instead of crashing#139
melvincarvalho merged 1 commit into
gh-pagesfrom
issue-138-econnreset

Conversation

@melvincarvalho

Copy link
Copy Markdown
Contributor

Summary

  • Add Fastify clientErrorHandler to silently handle ECONNRESET, EPIPE, and ECONNABORTED at the socket level
  • Add process-level uncaughtException safety net for any TCP errors that escape Fastify
  • Prevents server crashes from normal network noise (browser navigation, health checks, aborted requests)

Closes #138

Test plan

  • Verify existing test suite passes
  • Deploy behind haproxy and confirm no crashes on connection resets
  • Confirm non-TCP uncaught exceptions still crash with error output

Add Fastify clientErrorHandler to catch TCP reset errors at the socket
level, and a process-level uncaughtException safety net for any that
escape. Covers ECONNRESET, EPIPE, and ECONNABORTED.

Closes #138
@melvincarvalho
melvincarvalho merged commit 52b217e into gh-pages Feb 28, 2026
melvincarvalho added a commit that referenced this pull request Jul 26, 2026
)

* fix(did): lead DID document @context with did/v1 (did:nostr 0.1.1)

DID Core requires a DID document's @context to lead with
https://www.w3.org/ns/did/v1. did:nostr 0.1.1 adopted that ordering
(nostrcg/did-nostr#136, fixed by #139), so buildDidDocument now emits:

  [did/v1, cid/v1, w3id.org/nostr/context]

cid/v1 is retained because the document's Multikey verification method
comes from the Controlled Identifiers vocabulary.

The requirement is normative for DID documents only, so the standalone
Multikey resource (src/keys/provision.js) and the WebID profile
(src/webid/profile.js) correctly keep cid/v1 alone and are untouched.

Both orderings expand to the same terms under JSON-LD, so existing
documents do not break; JSS's own consumer (src/auth/did-nostr.js) never
reads @context — it keys on verificationMethod.

Updates the full-shape assertion and adds a dedicated regression test for
the leading context, so a reordering failure names itself.

Closes #617

* test(did): assert @context shape before indexing

The dedicated ordering test indexed doc['@context'] and called .includes()
without first checking the field exists, so a regression that dropped
@context entirely would surface as a TypeError instead of the intended
assertion message — defeating the reason the check is a separate test.

Bind @context to a local, assert Array.isArray first, then check the
ordering. Verified: with @context removed from the builder the test now
fails with '@context must be present and an array' rather than a
TypeError.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Server crashes on ECONNRESET (unhandled TCP reset)

1 participant