Repository navigation
fix: return callNotFound for directories without index file - #626
Merged
Merged
Conversation
When a directory without an index file was requested, pumpSendToReply called reply.callNotFound() without returning it, so the route handler promise resolved before the not-found handler finished. A not-found handler using reply.sendFile() then produced an empty 200 response and FST_ERR_REP_ALREADY_SENT. Fixes #625 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SameRainbows
reviewed
Nov 4, 2026
SameRainbows
left a comment
There was a problem hiding this comment.
LGTM. Verified locally on Node 24 and against the test suite.
Returning reply.callNotFound() cleanly preserves the thenable chain in pumpSendToReply, allowing the not-found handler's async stream to complete before Fastify terminates the response. All 18 CI matrix jobs and CodeQL checks are green.
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.
Fixes #625
Problem
Since 10.1.8, a request for a directory with no index file (and
redirectoff) returned an empty200when the not-found handler usedreply.sendFile(...). It also loggedFST_ERR_REP_ALREADY_SENT.In that branch,
pumpSendToReplycalledreply.callNotFound()without returning it. The wildcard handler now returnspumpSendToReply(...), so its promise resolved toundefinedbefore the not-found handler finished streaming. Fastify then sent an empty reply.Fix
return reply.callNotFound()there, the same as every othercallNotFound()call inpumpSendToReply.Tests
Added a regression test that requests
/deep(a directory with no index) with asetNotFoundHandlerthat callsreply.sendFile('index.html'). It fails onmainand passes with this change. Full suite passes with 100% coverage, and lint is clean.🤖 Generated with Claude Code