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

Đang mở Phù hợp với người mới
#25,950 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
68/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
node.js, typescript
Lĩnh vực
backend

Hướng nghiên cứu

Bắt đầu bằng cách chạy bản tái hiện tối thiểu trong ESM gốc, sau đó kiểm tra mã nguồn tương ứng với build/esm/integrations/fs/vendored/instrumentation.js, đặc biệt là _patchMethod và cách nó nhập fs. Hoàn thành khi fsIntegration khởi tạo mà không bị lỗi trong ESM gốc; hãy xác minh rằng giải pháp tạm thời dùng CommonJS vẫn hoạt động.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
TypeScript
Star
8.8k
Fork
1.9k
Merge trung bình
1 ngày 19 giờ
Pull request đã merge (30 ngày)
664

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của getsentry/sentry-javascript

Tất cả issue của getsentry/sentry-javascript

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.