Closed leonitousconforti closed 9 months ago
One possible idea I have right now is that if Effect.async
behaves similar to Promises in JS, i.e once they are "settled" they can't change, then in this block: https://github.com/Effect-TS/platform/blob/0f19070a9fc9d2f3faa7c0191c47af65ccfcfece/packages/platform-node/src/internal/http/nodeClient.ts#L154-L172
since the finish
event is emitted before the error
event in this case, the effect is "settled" with a success instead of the failure? I just tested this by commenting out the:
nodeRequest.on("finish", () => {
console.log("finish")
resume(Effect.unit);
});
and the error does indeed bubble up now. No idea why the finish
event is emitted first in this case
Ok I think I can follow what is going on now,
calls sendBody
and waitForResponse
. Since this request has no body, sendBody
goes straight to waitForFinish
which I infer means something like "wait for the request to finish." Reading what the docs for the events emitted from the http request, the finish
event means "the request has been sent. More specifically, this event is emitted when the last segment of the response headers and body have been handed off to the operating system for transmission over the network." I don't think that tweaking the event listeners in this section like I was trying will help at all, as if the request has truly been finished then I think this section should succeed.
I do think that there needs to be another error event listener added in the waitForResponse
method though. And adding one there does indeed fix my issue
I am working with the platform-node implementation of the effect http client and am experiencing an issue where when the remote server closes/destroys the socket (and an ECONNRESET error is thrown) the http request hangs forever. I've created a minimal reproducible example which you can find below. I think this behavior is a bug and would be willing to submit a PR but I am still quite slow at debugging this library so any help/pointers would be appreciated. If you don't think this is a bug, could you explain why this is desired and how I might be able to avoid it?
oh and node v20.10.0