Skip to content

fix: set headerSent flag#191

Merged
Eomm merged 2 commits into
mainfrom
jek
May 24, 2026
Merged

fix: set headerSent flag#191
Eomm merged 2 commits into
mainfrom
jek

Conversation

@Eomm
Copy link
Copy Markdown
Member

@Eomm Eomm commented May 24, 2026

This fix sets the https://nodejs.org/api/http.html#responseheaderssent value for express+fastify

Since Express error middleware chains execute synchronously, a second middleware runs before writableEnded becomes true. It sees res.headersSent === false and calls res.json() again, triggering a second reply.send() → a second onSend chain → a second safeWriteHead → boom.

Checklist

@Eomm Eomm merged commit d767fd6 into main May 24, 2026
17 checks passed
@Eomm Eomm deleted the jek branch May 24, 2026 12:03
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.

3 participants