fix(node-fetch-server): fix logic for aborting requests#10726
Merged
mjackson merged 1 commit intoremix-run:mainfrom Sep 11, 2025
Merged
fix(node-fetch-server): fix logic for aborting requests#10726mjackson merged 1 commit intoremix-run:mainfrom
mjackson merged 1 commit intoremix-run:mainfrom
Conversation
47cf447 to
7b43c2d
Compare
brophdawg11
reviewed
Sep 10, 2025
| // `finish` -> done rendering the response | ||
| // `close` -> response can no longer be written to | ||
| res.on('close', () => controller?.abort()) | ||
| res.on('finish', () => (controller = null)) |
Contributor
There was a problem hiding this comment.
@mjackson Here's a small repro of the issue we discovered in React Router that we fixed with this change. If we only use the close event to trigger aborting request signals, then we inadvertently also abort on successful/non-interrupted requests:
import * as http from 'node:http';
import { createRequestListener } from '@remix-run/node-fetch-server';
function handler(request) {
// This should only fire if the request was interrupted
request.signal.addEventListener('abort', () => console.log('request aborted'));
return new Response('Hello, world!');
}
let server = http.createServer(createRequestListener(handler));
server.listen(3000);Instead, we want to listen for a close event that was not preceded by a finish event. finish means we successfully finished sending response, so there is no longer any need to abort once we receive that.
Member
|
Thanks, @MichaelDeBoey 🙏 |
Member
|
Released in node-fetch-server v0.8.1 |
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.
Taken from @brophdawg11's #10046 & remix-run/react-router@d386c0d