Closed Gemerich closed 2 years ago
Hi @Gemerich, thanks for reporting. Can you please also describe the version of Node.js you are using and the Operating System? I can't reproduce your issue as you describe it.
Thanks
Sorry for the delay! I got covid last week and was away from work. My node version is 14.17.0 and I'm running on a MacOs BigSur 11.6
@jkyberneees I was able to replicate provided downstream exists and it crashes during the response, hence upstream to gateway leads to above error on fast-gateway@2.9.4
andnodejs@14.16.0
. IMHO it's probably because end
is being called multiple times in fast-proxy@2.0.0
. I assume it's also present in fast-proxy-lite
.
// index.js line 90
if (!res.sent) {
if (err.code === 'ECONNREFUSED' || err.code === 'ERR_HTTP2_STREAM_CANCEL') {
res.statusCode = 503
res.end('Service Unavailable')
} else if (err.code === 'ECONNRESET' || err.code === 'UND_ERR_HEADERS_TIMEOUT' || err.code === 'UND_ERR_BODY_TIMEOUT') {
res.statusCode = 504
res.end(err.message)
} else {
res.statusCode = 500
res.end(err.message)
}
}
@Gemerich Hope you're feeling better :)
Hi @iapain, very much appreciated. I will reproduce and push the fix ASAP.
@Gemerich Hope you're feeling better :)
+1
Hey @iapain, @Gemerich, I have to admit I am still not able to reproduce the issue. Could you please detail the steps so I can reproduce?
Thanks in advance.
I think the catch here is to call a route that doens't exists. On the example I used the route is /v1/test and you should try to call /v1/test/aa. Your gateway returns Service Unavailble normally? The service that you're pointing must not exist.
@Gemerich @jkyberneees TBH this happens randomly. Try bombarding gateway with multiple concurrent connections using bench marking tool.
Hi @Gemerich and @iapain, thanks for bringing more details into this issue. I have released a minor patch in this direction inside fast-proxy-lite
.
Can you please try out v3.0.2 of fast-gateway
? https://github.com/BackendStack21/fast-gateway/releases/tag/v3.0.2
I am still unable to repro this issue in Node v16.13.1
Curious to see if you are still able to reproduce this issue.
Regards
Hi @jkyberneees
Many thanks! It's fixed in v3.0.2 :)
Cheers!
Thanks @iapain , @Gemerich can you confirm this issue is now resolved on your side as well?
When the gateway routes to a route that is unavailable, the gateway crashes and return ERR_STREAM_WRITE_AFTER_END
Steps to reproduce the behavior:
Expected behavior
The gateway should return 'Service unavailable' error
Returned behavior
The gateway return 'Service unavailable' error but the gateway crashes with stack:
Additional context
The main.ts file:
package.json file:
tsconfig.json file: