Skip to content
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

Capture socket in response finish callback closure directly rather than relying on request object #27

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

Conversation

mikegreiling
Copy link

In certain circumstances, a request object's socket will be disassociated or destroyed prior to the response's finish event firing. In this case, req.socket will be null. This change ensures that the .on('finish') closure will reference the socket directly rather than referencing it through the request.

uncaughtException: TypeError: Cannot set properties of null (setting '_isIdle')
    at ServerResponse.<anonymous> (/Users/admin/Projects/home-portal/node_modules/http-graceful-shutdown/lib/index.js:160:26)
    at ServerResponse.emit (node:events:531:35)
    at onFinish (node:_http_outgoing:1031:10)
    at callback (node:internal/streams/writable:764:21)
    at afterWrite (node:internal/streams/writable:708:5)
    at afterWriteTick (node:internal/streams/writable:694:10)
    at process.processTicksAndRejections (node:internal/process/task_queues:81:21)

In certain circumstances, a request object's socket will be disassociated or destroyed prior to the response's finish event firing. In this case, `req.socket` will be `null`. This change ensures that the `.on('finish')` closure will reference the socket directly rather than the request.
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.

1 participant