Socket hang up error with Node 20 on second request using graphql-request

Description We've just switched from Node 18 to Node 20 on our project and we are currently facing a problem with a microservice deployed that does some multiple calls to another one using graphql-request. First call is working well but the other call raises the following error

    Fetch something: request to http://myurl.svc.cluster.local:3002/internal-graphql failed, reason: socket hang up

After some search it seems on node 20 and node 22 the default keep-alive value in createServer has been changed from false to true. It seems it causes error in graphql-request as the previous connection is not closed so we encounter the 'socket hang up' error.

I'm using [email protected]. Was not able yet to update to the last version due to esm compilation issues in typescript.

This error appears only when the microservice is deployed (on kubernetes in an Azure cluster). In local all is working fine. I have fixed this issue in another project by setting back the keep-alive option in createServer to false but for this particular it seems to have no effect.

    const server = createServer({ keepAlive: false }, app);

Did someone encountered this issue and has a workaround?

Related Links

Upvotes: 1

Views: 111

Answers (0)

Related Questions