fix(listener): return after handling GET /api/preferences/:userId#162
Open
giftexceed wants to merge 1 commit into
Open
fix(listener): return after handling GET /api/preferences/:userId#162giftexceed wants to merge 1 commit into
giftexceed wants to merge 1 commit into
Conversation
The GET preferences handler wrote its response but did not return, so execution fell through to the catch-all 404 handler, which called res.writeHead() again and threw "Cannot write headers after they are sent to the client". Add the explicit 200 + JSON content-type header and return after responding, matching the other route handlers. Fixes the failing "GET /api/preferences/:userId returns preferences for the given user" test in events-server.test.ts.
This was referenced Jun 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a crash in the listener's
GET /api/preferences/:userIdendpoint.The handler wrote its response with
res.end(...)but did notreturn, so execution fell through to the catch-all 404 handler at the bottom of the request listener, which calledres.writeHead(404, ...)on an already-sent response and threw:The fix sets the explicit
200status with a JSON content-type header andreturns after responding, matching every other route handler in the file.Why this matters for CI
This is one of two pre-existing test failures in the listener on
main(unrelated to any contract/dashboard work) that make the CI / Listener job red. This PR fixes theevents-server.test.tsfailure.Verification