Random timeouts when using ManagementAPI

Hi,

I am using the auth0 JS SDK, version 2.42.0 on a NextJS project.

I have been experiencing problems with the usage of the management API. Some times, and it seems very random from my observations, a given endpoint will time out. The same code will sometimes work, and one F5 later it will freeze timing out on a ManagementAPI call. I am experiencing this in a development environment.

Here is how I am creating the ManagementClient instance:

    auth0 = await new ManagementClient({
      domain: process.env.AUTH0_ISSUER_BASE_DOMAIN,
      clientId: process.env.AUTH0_CLIENT_ID,
      clientSecret: process.env.AUTH0_CLIENT_SECRET,
      scope: "read:users update:users read:users_app_metadata",
    });
  }

And here is an example of call that will sometimes freeze and timeout:

export default withApiAuthRequired(async function myApiRoute(req, res) {
    const { user } = getSession(req, res);
    const auth0User = await auth0.getUser({ id: user.sub });
   ...
}

And finally, the error after timing out:

error - SanitizedError [APIError]: connect ETIMEDOUT 104.xx.xxx.xxx:443
    at C:\my_project\node_modules\rest-facade\src\Client.js:402:25
    at Request.callback (C:\my_project\node_modules\superagent\lib\node\index.js:905:3)
    at ClientRequest.<anonymous> (C:\my_project\node_modules\superagent\lib\node\index.js:822:12)
    at ClientRequest.emit (node:events:513:28)
    at TLSSocket.socketErrorListener (node:_http_client:494:9)
    at TLSSocket.emit (node:events:513:28)
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  statusCode: 'ETIMEDOUT',
  requestInfo: {
    method: 'post',
    url: 'https://dev-xxxxxx.us.auth0.com/oauth/token'
  },

I tried using different machines and different internet providers, but no luck.
Is there some clue of what am I experiencing?

Thanks!

Maybe an issue with my ISP.
Using a VPN fixed my problem.

2 Likes

Gotchya… I guess we’ve all been there!