Skip to content

fix(node-core): Guard against undefined util.getSystemErrorMap#20660

Open
sentry[bot] wants to merge 1 commit intodevelopfrom
seer/fix/node-core-bun-compat
Open

fix(node-core): Guard against undefined util.getSystemErrorMap#20660
sentry[bot] wants to merge 1 commit intodevelopfrom
seer/fix/node-core-bun-compat

Conversation

@sentry
Copy link
Copy Markdown

@sentry sentry Bot commented May 4, 2026

The systemErrorIntegration in @sentry/node-core attempts to call util.getSystemErrorMap() to determine if an error is a Node.js SystemError. However, in environments like Bun (which provides a Node.js compatibility layer), util.getSystemErrorMap may be undefined.

This leads to a TypeError: util.getSystemErrorMap is not a function when Sentry tries to process any event, effectively crashing the Sentry event pipeline.

This change adds a typeof check for util.getSystemErrorMap within the isSystemError function. If the function is not available, isSystemError will now gracefully return false, preventing the TypeError and allowing Sentry's event processing to continue. This means that system error context enrichment will be skipped in environments where this specific util API is missing, which is the desired fallback behavior.

See also: oven-sh/bun#22872

Fixes XCODEBUILDMCP-1J

@chromy chromy marked this pull request as ready for review May 4, 2026 19:29
@chromy chromy requested a review from a team as a code owner May 4, 2026 19:29
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit d147bf4. Configure here.

// https://github.com/nodejs/node/issues/46869
if (typeof util.getSystemErrorMap !== 'function') {
return false;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix PR missing regression test for the guard

Low Severity

This fix PR adds a typeof guard for util.getSystemErrorMap but does not include any unit, integration, or e2e test verifying that isSystemError returns false when util.getSystemErrorMap is undefined. A regression test mocking util.getSystemErrorMap as undefined would confirm the fix works and prevent future regressions.

Fix in Cursor Fix in Web

Triggered by project rule: PR Review Guidelines for Cursor Bot

Reviewed by Cursor Bugbot for commit d147bf4. Configure here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a small unit test would be great I think :) I just noticed there are none yet but it should go in packages/node-core/test/integrations/systemError.test.ts.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@claude can you add this test?

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

size-limit report 📦

Path Size % Change Change
@sentry/browser 26.31 kB - -
@sentry/browser - with treeshaking flags 24.8 kB - -
@sentry/browser (incl. Tracing) 44.2 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 46.42 kB - -
@sentry/browser (incl. Tracing, Profiling) 49.16 kB - -
@sentry/browser (incl. Tracing, Replay) 83.58 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 73.04 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 88.26 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 100.87 kB - -
@sentry/browser (incl. Feedback) 43.47 kB - -
@sentry/browser (incl. sendFeedback) 31.12 kB - -
@sentry/browser (incl. FeedbackAsync) 36.21 kB - -
@sentry/browser (incl. Metrics) 27.62 kB - -
@sentry/browser (incl. Logs) 27.75 kB - -
@sentry/browser (incl. Metrics & Logs) 28.45 kB - -
@sentry/react 28.05 kB - -
@sentry/react (incl. Tracing) 46.42 kB - -
@sentry/vue 31.18 kB - -
@sentry/vue (incl. Tracing) 46.04 kB - -
@sentry/svelte 26.34 kB - -
CDN Bundle 28.91 kB - -
CDN Bundle (incl. Tracing) 46.95 kB - -
CDN Bundle (incl. Logs, Metrics) 30.34 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 48.06 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 69.41 kB - -
CDN Bundle (incl. Tracing, Replay) 84.11 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 85.16 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 89.91 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 91.01 kB - -
CDN Bundle - uncompressed 84.72 kB - -
CDN Bundle (incl. Tracing) - uncompressed 140.31 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 88.92 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 143.77 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 212.86 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 258.11 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 261.56 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 271.81 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 275.25 kB - -
@sentry/nextjs (client) 48.92 kB - -
@sentry/sveltekit (client) 44.67 kB - -
@sentry/node-core 59.14 kB +0.03% +15 B 🔺
@sentry/node 170.57 kB +0.01% +16 B 🔺
@sentry/node - without tracing 97.17 kB +0.02% +12 B 🔺
@sentry/aws-serverless 114 kB +0.04% +36 B 🔺
@sentry/cloudflare (withSentry) - minified 165.2 kB - -
@sentry/cloudflare (withSentry) 417.71 kB - -

View base workflow run

Copy link
Copy Markdown
Member

@nicohrubec nicohrubec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change lgtm! I agree with cursor that a small test would be good to catch future regressions, but else I think this is good to merge from my side.

// https://github.com/nodejs/node/issues/46869
if (typeof util.getSystemErrorMap !== 'function') {
return false;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a small unit test would be great I think :) I just noticed there are none yet but it should go in packages/node-core/test/integrations/systemError.test.ts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants