fsIntegration crashes in native ESM when patching the read-only fs namespace

Offen Anfängerfreundlich
#25,950 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
68/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
node.js, typescript
Bereich
backend

Rechercherichtung

Führe zunächst die minimale Reproduktion in nativem ESM aus und untersuche dann den Quellcode, der build/esm/integrations/fs/vendored/instrumentation.js entspricht, insbesondere _patchMethod und den Import von fs. Das Ziel ist erreicht, wenn fsIntegration in nativem ESM ohne Absturz initialisiert wird; überprüfe, dass die CommonJS-Umgehung weiterhin funktioniert.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Bug Node.js
Environment
  • @sentry/node 11.10.0
  • Node.js 24.22.1, Linux x64
  • Native ESM, no bundler
Minimal reproduction
import { fsIntegration } from '@sentry/node';
fsIntegration().setupOnce?.();

Run with node --input-type=module (or save as .mjs). The same failure occurs when registering fsIntegration() through Sentry.init().

Actual behavior

The process throws asynchronously:

TypeError: Cannot assign to read only property 'accessSync' of object '[object Module]'

The stack points to _patchMethod in build/esm/integrations/fs/vendored/instrumentation.js.

Expected behavior

Filesystem instrumentation initializes in native ESM without crashing.

Cause and workaround

The ESM implementation imports * as fs from 'fs' and then assigns wrappers to that read-only module namespace. Loading the integration from the public CommonJS build with createRequire() works. Using the mutable default fs export fixes the crash; calling syncBuiltinESMExports() afterward also refreshes named ESM bindings.

Vorherrschende Sprache
TypeScript
Sterne
8.8k
Forks
1.9k
Ø Merge
1 T. 19 Std.
Gemergte PRs (30 T.)
664

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus getsentry/sentry-javascript

Alle Issues in getsentry/sentry-javascript

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.