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

未關閉 適合新手
#25,950 2 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
68/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
node.js, typescript
領域
backend

研究方向

先在原生 ESM 中執行最小重現,接著檢查對應於 build/esm/integrations/fs/vendored/instrumentation.js 的原始碼,特別是 _patchMethod 以及它如何匯入 fs。完成的標準是 fsIntegration 在原生 ESM 中初始化時不會當機;請確認 CommonJS 變通方案仍可運作。

由索引模型根據 Issue 內容生成。

描述

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.

主要語言
TypeScript
星號
8.8k
分支
1.9k
平均合併
1 天 19 小時
30 天內合併 PR
664

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

getsentry/sentry-javascript 的其他 Issue

查看 getsentry/sentry-javascript 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。