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

http2 (client): Error [ERR_HTTP2_INVALID_SESSION]: The session has been destroyed #14964

Closed
AndrewBarba opened this issue Aug 21, 2017 · 1 comment
Labels
http2 Issues or PRs related to the http2 subsystem.

Comments

@AndrewBarba
Copy link

AndrewBarba commented Aug 21, 2017

  • Version: Node.js 8.4.0
  • Platform: Heroku
  • Subsystem: Cedar-16 stack

I don't see this too often but once in a while it is showing up in my logs without a trace back to anything in my code. Below is a full class definition for a very basic http2-client library that I'm using to connect to Apple's HTTP/2 Push Notification API.

app/web.1: error:  Error [ERR_HTTP2_INVALID_SESSION]: The session has been destroyed 
app/web.1:     at ClientHttp2Session.shutdown (internal/http2/core.js:994:13) 
app/web.1:     at ClientHttp2Session.emitGoaway (internal/http2/core.js:377:10) 
app/web.1:     at _combinedTickCallback (internal/process/next_tick.js:131:7) 
app/web.1:     at process._tickDomainCallback (internal/process/next_tick.js:218:9) 
app/web.1: worker 1  disconnected. suicide false 

A couple things I could be doing incorrectly:

  1. I am only connecting once and holding onto returned client for subsequent requests
  2. I clean up the client only if .destroyed !== true or I receive a GOAWAY frame
  3. I am setting up a request timeout but not a session timeout (didn't see docs for session timeout?)

Code:
https://github.com/AndrewBarba/apns2/blob/node/http2/lib/http2-client.js

@jasnell
Copy link
Member

jasnell commented Aug 21, 2017

There's likely a race condition in the timeout code. The error is occurring because some bit of code (most likely the timeout) is attempting to fire after the session has already been destroyed. I'll take a look and verify.

@jasnell jasnell added the http2 Issues or PRs related to the http2 subsystem. label Aug 21, 2017
jasnell added a commit to jasnell/node that referenced this issue Aug 31, 2017
Guard against destroyed session in timeouts and goaway event.

Improve timeout handling a bit.

Fixes: nodejs#14964
@jasnell jasnell closed this as completed in 09480a8 Sep 5, 2017
MylesBorins pushed a commit that referenced this issue Sep 10, 2017
Guard against destroyed session in timeouts and goaway event.

Improve timeout handling a bit.

PR-URL: #15106
Fixes: #14964
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
MylesBorins pushed a commit that referenced this issue Sep 11, 2017
Guard against destroyed session in timeouts and goaway event.

Improve timeout handling a bit.

PR-URL: #15106
Fixes: #14964
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
MylesBorins pushed a commit that referenced this issue Sep 12, 2017
Guard against destroyed session in timeouts and goaway event.

Improve timeout handling a bit.

PR-URL: #15106
Fixes: #14964
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
addaleax pushed a commit to addaleax/node that referenced this issue Sep 13, 2017
Guard against destroyed session in timeouts and goaway event.

Improve timeout handling a bit.

PR-URL: nodejs#15106
Fixes: nodejs#14964
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
http2 Issues or PRs related to the http2 subsystem.
Projects
None yet
Development

No branches or pull requests

2 participants