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

IncomingMessage will emit end after aborted #27981

Closed
ronag opened this issue May 30, 2019 · 5 comments
Closed

IncomingMessage will emit end after aborted #27981

ronag opened this issue May 30, 2019 · 5 comments
Labels
http Issues or PRs related to the http subsystem.

Comments

@ronag
Copy link
Member

ronag commented May 30, 2019

I encountered this while working on my nodejs based proxy server and retries of GET requests.

It turns out that when an upstream server dies the nodejs requests in the proxy will emit the following events:

aborted
end
close

The end event I find a little strange to receive after a connection has been forcefully aborted.

Can someone confirm whether this is intentional or not?

@ronag
Copy link
Member Author

ronag commented May 30, 2019

It would be much easier if it didn't end after aborted. That way I can choose the behavior. As it is now I can't use pipe or pipeline if I don't want this behavior.

But I also can't not use pipe since the following commit has not been merged into LTS (20c3ac2), i.e. none pipe based streaming is broken...

I'm a little stuck at the moment...

@ronag
Copy link
Member Author

ronag commented May 30, 2019

OSX, Node 10.13.0

const http = require('http')

http.createServer(function (req, res) {
  res.write(Buffer.alloc(32))
  setTimeout(() => (
    res.destroy()
  ), 1000)
}).listen(0, function () {
  http.request({
    port: this.address().port,
    method: 'GET',
    path: '/'
  }).on('response', res => res
    .on('data', () => {})
    .on('aborted', () => console.log('aborted'))
    .on('end', () => console.log('end'))
    .on('close', () => console.log('close'))
  ).end()
})

Will print

aborted
end
close

@lpinca
Copy link
Member

lpinca commented Jun 4, 2019

Issue title is misleading, ClientRequest extends OutgoingMessage and does not emit 'end'. It should be IncomingMessage.

@lpinca lpinca added the http Issues or PRs related to the http subsystem. label Jun 4, 2019
@ronag ronag changed the title ClientRequest will emit end after aborted IncomingMessage will emit end after aborted Jun 4, 2019
@Trott
Copy link
Member

Trott commented Oct 14, 2019

Landed in 5f80df8

@Trott Trott closed this as completed Oct 14, 2019
@Trott
Copy link
Member

Trott commented Oct 14, 2019

Whoops! Wrong window! But now that that landed, I think this can be closed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
http Issues or PRs related to the http subsystem.
Projects
None yet
Development

No branches or pull requests

3 participants