Skip to content

How to handle server-side session close (sporadic GOAWAY) #409

@gunters63

Description

@gunters63

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the issue has not already been raised

Issue

In our project we are using fastify and @fastify/http-proxy as a reverse proxy to forward requests to an internal GraphQL service..

Sometimes, very sporadically, we have the effect that the forwarding gets stuck with fastify logging a GOAWAY error.

In the logs the exception looks like this

Error [ERR_HTTP2_GOAWAY_SESSION]: New streams cannot be created after receiving a GOAWAY
              at ClientHttp2Session.request (node:internal/http2/core:1757:13)
              at y (file:///data/asc/application/services/web-server/web-server.mjs:616:12700)

If we look in the Node source code, we can see the error is thrown here:

Image

It seems the GraphQL server somehow closed the connection server-side.
It is currently not clear why he does this. We are still investigating.

Anyway, if we look in the source of fastify-reply-from, we can see the request which threw the exception here (in handleHttp2Req):

Image

This the same source location than our stack trace (file:///data/asc/application/services/web-server/web-server.mjs:616:12700) in our bundled web server.

Strangely, to recover from this error, it doesn´t help to restart the GraphQL server, we have to restart the fastify proxy.

We will still try to find out why the GraphQL server closed the connection from his side in the first place, but beside that:

  • Is there a way to recover cleanly from this situation?
  • Nodes http2Client.request immediately throws exceptions when the session was destroyed or closed. Wouldn't it be better if fastify-reply-from re-created the httpclient in this case and retried?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions