Skip to content
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

request error read ECONNRESET #3750

Open
dowmeister opened this issue Oct 19, 2024 · 5 comments
Open

request error read ECONNRESET #3750

dowmeister opened this issue Oct 19, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@dowmeister
Copy link

Bug Description

Probably this is not even a bug but is driving me crazy and i'm asking for help (or an hug)

Context is an Electron app based on Electron 22 and Node v16, sometimes POST or PATCH requests fail with read ECONNRESET error at TLSWrap.onStreamRead (node:internal/stream_base_commons:217:20)

Other requets work fine, this happens for some users, mostly - for what i've seen - connected to internet with a wireless connection that probably is not really stable, but the app works totally fine and is offline tolerant, the game they are playing on has a multiplayer module that needs to be connected to internet and don't lose the connection.

Axios or undici there is no difference, for same users, fails in the same way.

Among other things, the app sends a POST request in a certain moment - and it works - after a while, for other reasons, sends other POSTS requests and these fails for ECONNRESET.

I'm asking for help to understand how debug this, find a reliable reason or eventually fix it.

I've never reproduced this situation, considering the app has thousands concurrent users, this happens to a relatively small users portion, but still, it happens.

Posted data is pretty simple:

{"job_id":14039010,"event_type":"tollgate_paid","x":-5502.788726806641,"y":65.37895965576172,"z":28128.698669433594,"attributes":{"amount":6}}

Is something with keepAlive? TLS protocols? IP resolution? mixed IPV6/IPV4 network?

Thaks for your help and sorry if is not related.

Reproducible By

Expected Behavior

Logs & Screenshots

Environment

Electron 22
Node 16
Windows 11 or 10

Additional context

@dowmeister dowmeister added the bug Something isn't working label Oct 19, 2024
@dowmeister dowmeister changed the title Request error read ECONNRESET request error read ECONNRESET Oct 19, 2024
@Ethan-Arrowood
Copy link
Collaborator

Not much we can do without some sort of reproduction. ECONNRESET issues can happen for a variety of reasons. Since you mentioned it happens regardless of the client, I suspect it is something in your application code.

connected to internet with a wireless connection that probably is not really stable

Are you able to reproduce by doing something like canceling a request while it is mid-execution?

@dowmeister
Copy link
Author

thanks for getting back to me.

i would be happy is something in my application code, at least would mean is fixable :D

can it be caused by the fact that functions are exported directly and not encapsulated in an class instance? maybe is something with resuing a closed connection?

 const result = await TruckyHubApiService.completeJobPost(
            remote_job_id as number,
            data
          );
export default {
...
  cancelJobPost,
...
};
async function completeJobPost(
  job_id: number,
  job: Job
): Promise<CompleteJobResponse> {
  return executeRequest(
    `/v1/job/${job_id}/complete`,
    'POST',
    job,
    true
  ) as Promise<CompleteJobResponse>;
}

do you have any suggestion to simulate the request cancelling in mid-execution?

Thanks again

@metcoder95
Copy link
Member

We will be able to help you better if you can isolate the problem as much as you can by providing an
Minimum Reproducible Example

@Ethan-Arrowood
Copy link
Collaborator

Ethan-Arrowood commented Oct 21, 2024

can it be caused by the fact that functions are exported directly and not encapsulated in an class instance?

No, most likely this is not the issue.

maybe is something with resuing a closed connection?

Yes, if a connection is closed, and it is being reused directly then it would result in an ECONNRESET error. Undici guards against this. Are you doing some unique with the API?

@dowmeister
Copy link
Author

No, all stateless requests authenticated with authorization header, nothing fancy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants
@dowmeister @metcoder95 @Ethan-Arrowood and others