Skip to content

Add req.socket.destroy() #339

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

yus-ham
Copy link

@yus-ham yus-ham commented Feb 26, 2025

Checklist

This ensures invocation to req.socket.destroy() won't makes exception thrown as it happen before in my express app

125 |     // cannot actually respond
126 |     if (headersSent(res)) {
127 |       debug('cannot %d after headers sent', status)
128 |       if (req.socket) {
129 |         console.info('finalhandler req.socket:',req.socket)
130 |         req.socket.destroy()
                         ^
TypeError: req.socket.destroy is not a function. (In 'req.socket.destroy()', 'req.socket.destroy' is undefined)
      at <anonymous> (/app/node_modules/finalhandler/index.js:130:20)

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mcollina mcollina requested review from simoneb and jsumners February 26, 2025 18:04
Copy link
Member

@jsumners jsumners left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems reasonable, but I wonder what the use case is that makes it necessary. This library has been around for a long time without any reports of this being a problem.

Basically, a test has been included to assert that the method exists and doesn't do anything, but there is not a test that shows what is being fixed.

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