ReferenceError: Cannot access 'ManagementError' before initialization

Ouverte
#1,434 0 commentaires 3 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
3/5
Temps estimé
1-2 jours
Accessibilité débutants
70/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
node.js, typescript
Domaine
backend, devtools

Piste de recherche

Start with the generated ManagementTimeoutError.ts and the errors barrel it imports, then check how Fern generates this file and how the ESM build is produced. Reproduce the import failure without creating an Auth0 client or making a network request. Done when the generated error imports ManagementError directly, the cycle is removed, and importing the ESM build succeeds while public exports remain intact.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

bug
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

ESM import can access ManagementError before initialization

Summary

Importing the ESM build can fail during module initialization with:

ReferenceError: Cannot access 'ManagementError' before initialization
    at .../auth0/dist/esm/management/errors/ManagementTimeoutError.mjs:3:52

The failure occurs before an Auth0 client is instantiated or a network request is made, so no Auth0 credentials are required to investigate it.

Suspected cause

ManagementTimeoutError imports the errors barrel and extends its ManagementError export:

import * as errors from "./index.js";

export class ManagementTimeoutError extends errors.ManagementError {}

The barrel also exports ManagementTimeoutError, producing this cycle:

ManagementTimeoutError -> errors/index -> ManagementTimeoutError

Proposed generator change

Generate a direct dependency on the base error instead:

import { ManagementError } from "./ManagementError.js";

export class ManagementTimeoutError extends ManagementError {}

This removes the error module's barrel cycle while preserving the package's public exports.

Notes for maintainers

ManagementTimeoutError.ts is generated by Fern so I didn't create a PR in this repo for it, not sure how that is typically handled.

Reproduction

I ran into this with a simple import in an ESM project -- happy to create a repro repository if needed.

Additional context

No response

node-auth0 version

7.6.0

Node.js version

26.12

Langage dominant
TypeScript
Étoiles
683
Forks
319
Merge moyen
1 j 30 min
PR mergées (30 j)
13

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de auth0/node-auth0

Toutes les issues de auth0/node-auth0

Issues similaires

Plus d'issues TypeScript

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.