restify / restify/node-restify
Error when response already destroyed
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 10.7k
- Forks
- 975
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 5
Description
- Used appropriate template for the issue type
- Searched both open and closed issues for duplicates of this issue
- Title adequately and concisely reflects the feature or the bug
Restify Version: 10.0.0
Node.js Version: 18.12.1
Expected behaviour
once the response is closed or sent to the client, the "chain handler" must be terminated
Actual behaviour
The "chain handler" still continues when the response has been destroyed
Repro case
case 1:
server.get('*',async(req, res) => {
console.log('----first----');
res.send('first');
}, async(req, res) => {
console.log('----second----');
res.send('second');
});

case 2:
server.get('*', async(req, res) => {
console.log('----first----');
res.send('first');
}, (req, res, next) => {
console.log('----second----');
res.send('second');
});

Cause
Are you willing and able to fix this?
yes
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at lib/chain.js around line 143, which the report identifies as the cause, and reproduce both request-handler cases from the issue. Trace how the chain proceeds after res.send or response destruction. Done means the chain handler terminates once the response is closed or sent, without invoking the second handler.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100