-
Notifications
You must be signed in to change notification settings - Fork 284
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: How should I be avoiding "New streams cannot be created after receiving a GOAWAY" errors #2105
Comments
@nodejs/http2 |
Can anyone help me with this? |
After receiving a GOAWAY you cannot create new streams on the sessions. This is part of the http2 protocol. It is not clear what kind of help do you need on this.. would you mind to add some code to reproduce? |
As @mcollina mentioned, here's relevant HTTP/2 spec which explains new streams can't be created after GOAWAY frame https://http2.github.io/http2-spec/#GOAWAY
|
I understand that new streams cannot be created after receiving a GOAWAY. I am trying to understand how to use the |
I think having an example that reproduce the error would help, as well as a stacktrace. |
I don't know much about
is this indication of any racy behavior? $ cat 2105.js const h = require('http2')
const s = h.createServer()
s.on('session', (session) => {
session.on('goaway', (e, l, o) => {
console.log(`${e}, ${l}, ${o}`)
s.close()
})
})
s.listen(12000, () => {
const c = h.connect('http://localhost:12000')
const q = c.request()
q.on('error', (e) => {
console.log(e)
s.close()
})
setTimeout(() => {
c.close()
}, +process.argv[2])
})
|
Completely unrelated to gRPC, I just ran into this as well. I am handling the const session = http2.connect(`https://${host}`);
session
.on('error', e => {
console.error(`*ERROR*: ${e}`);
delete sessions[host];
})
.on('goaway', (errorCode, lastStreamId) => {
console.error(`*GOAWAY*: ${errorCode} : ${lastStreamId}`);
delete sessions[host];
}); But when making a request by running: const req = session.request(headers); I get the error:
I would expect to get a |
Sorry to answer an old issue. I just came to it because @murgatroid99 mentioned it in nodejs/TSC#1168.
No, in fact, this is expected. When a From the source code: // When a ClientHttp2Session is first created, the socket may not yet be
// connected. If request() is called during this time, the actual request
// will be deferred until the socket is ready to go. The example provided by @gireeshpunathil is basically sending a I'll create a PR to improve the |
@murgatroid99 if you think this has not been properly addressed.. could you please include some code to reproduce your problem? |
ping @murgatroid99 |
It seems there has been no activity on this issue for a while, and it is being closed in 30 days. If you believe this issue should remain open, please leave a comment. |
It seems there has been no activity on this issue for a while, and it is being closed. If you believe this issue should remain open, please leave a comment. |
I maintain the module
@grpc/grpc-js
which uses thehttp2
module. I have gotten reports of occasional "New streams cannot be created after receiving a GOAWAY" errors. The code I have listens for theclose
,error
, andgoaway
events, and if it sees any of them it stops using that session. Is that the intended usage pattern to avoid that kind of error? Is there anything else I should be checking to more consistently avoid that error?The text was updated successfully, but these errors were encountered: