Skip to content

Error when response already destroyed #1941

@misyuari

Description

@misyuari
  • 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');
});

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

if (!handler || req.connectionState() === 'close') {

Are you willing and able to fix this?

yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions