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

"Socket hang up" not handled by Retry configuration #1020

Open
5 tasks done
kbkk opened this issue Jul 10, 2024 · 0 comments
Open
5 tasks done

"Socket hang up" not handled by Retry configuration #1020

kbkk opened this issue Jul 10, 2024 · 0 comments
Labels
bug This points to a verified bug in the code

Comments

@kbkk
Copy link

kbkk commented Jul 10, 2024

Checklist

  • I have looked into the Readme, Examples, and FAQ and have not found a suitable solution or answer.
  • I have looked into the API documentation and have not found a suitable solution or answer.
  • I have searched the issues and have not found a suitable solution or answer.
  • I have searched the Auth0 Community forums and have not found a suitable solution or answer.
  • I agree to the terms within the Auth0 Code of Conduct.

Description

We occasionally see failed auth0 requests due to "socket hang up" - it causes our app's flow to break as we didn't expect this is something that needs handling.

The existing retry implementation can only handle failed requests based on statusCode, which does not apply in this case:

result = await action();
if ((retryWhen || [429]).includes(result.status) && nrOfTries < nrOfTriesToAttempt) {
nrOfTries++;

Expectations:

  • Allow retrying on "socket hang up" and possibly other network related errors
  • Provide new defaults for Retry, including "socket hang up"

Logs and traces:

      "fields": {
        "exception.message": "socket hang up",
        "exception.type": "ECONNRESET",
        "event": "exception",
        "exception.stacktrace": "Error: socket hang up\n    at connResetException (node:internal/errors:720:14)\n    at TLSSocket.socketOnEnd (node:_http_client:525:23)\n    at TLSSocket.emit (node:events:529:35)\n    at TLSSocket.emit (node:domain:489:12)\n    at endReadableNT (node:internal/streams/readable:1400:12)\n    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)"
      },
    "duration": 702769,
    "http.url": "https://my-tenant.us.auth0.com/oauth/token",
    "http.target": "/oauth/token",
    "otel.status_description": "socket hang up",
APIError: socket hang up
at /usr/src/app/node_modules/rest-facade/src/Client.js:402:25
at Request.callback (/usr/src/app/node_modules/rest-facade/node_modules/superagent/lib/node/index.js:943:3)
at ClientRequest.<anonymous> (/usr/src/app/node_modules/rest-facade/node_modules/superagent/lib/node/index.js:860:12)

Reproduction

  1. I cannot think of an easy reproduction - probably needs some fault injection/mocking to trigger it easily.

Sample code:

export const authClient = new AuthenticationClient({
  domain: config.domain,
  clientId: config.clientId,
  clientSecret: config.clientSecret,
});

await authClient.passwordGrant({
      username: user_email,
      password: user_password,
      audience: config.audience,
    });

Additional context

No response

node-auth0 version

3.7.2

Node.js version

18.20.4

@kbkk kbkk added the bug This points to a verified bug in the code label Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This points to a verified bug in the code
Projects
None yet
Development

No branches or pull requests

1 participant