node-restify icon indicating copy to clipboard operation
node-restify copied to clipboard

Error when response already destroyed

Open misyuari opened this issue 3 years ago • 0 comments

  • [x] Used appropriate template for the issue type
  • [x] Searched both open and closed issues for duplicates of this issue
  • [x] 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'); });

image

case 2:

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

image

Cause

https://github.com/restify/node-restify/blob/adf24c1046022b1ed2a284556ff0cc9b1777ade2/lib/chain.js#L143

Are you willing and able to fix this?

yes

misyuari avatar Feb 05 '23 13:02 misyuari