Skip to content

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

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

fix(node-core): Guard against undefined util.getSystemErrorMap#20660
sentry[bot] wants to merge 2 commits 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
Comment thread packages/node-core/src/integrations/systemError.ts
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

size-limit report 📦

⚠️ Warning: Base artifact is not the latest one, because the latest workflow run is not done yet. This may lead to incorrect results. Try to re-run all tests to get up to date results.

Path Size % Change Change
@sentry/browser 26.3 kB - -
@sentry/browser - with treeshaking flags 24.78 kB - -
@sentry/browser (incl. Tracing) 44.17 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 46.39 kB - -
@sentry/browser (incl. Tracing, Profiling) 49.14 kB - -
@sentry/browser (incl. Tracing, Replay) 83.55 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 73.01 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 88.23 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 100.84 kB - -
@sentry/browser (incl. Feedback) 43.44 kB - -
@sentry/browser (incl. sendFeedback) 31.11 kB - -
@sentry/browser (incl. FeedbackAsync) 36.19 kB - -
@sentry/browser (incl. Metrics) 27.6 kB - -
@sentry/browser (incl. Logs) 27.73 kB - -
@sentry/browser (incl. Metrics & Logs) 28.43 kB - -
@sentry/react 28.04 kB - -
@sentry/react (incl. Tracing) 46.4 kB - -
@sentry/vue 31.18 kB - -
@sentry/vue (incl. Tracing) 46.02 kB - -
@sentry/svelte 26.32 kB - -
CDN Bundle 28.91 kB - -
CDN Bundle (incl. Tracing) 46.94 kB - -
CDN Bundle (incl. Logs, Metrics) 30.34 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 48.04 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 69.4 kB - -
CDN Bundle (incl. Tracing, Replay) 84.07 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 85.15 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 89.89 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 90.97 kB - -
CDN Bundle - uncompressed 84.88 kB - -
CDN Bundle (incl. Tracing) - uncompressed 140.44 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 89.08 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 143.9 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 212.99 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 258.24 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 261.69 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 271.94 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 275.38 kB - -
@sentry/nextjs (client) 48.9 kB - -
@sentry/sveltekit (client) 44.64 kB - -
@sentry/node-core 59.82 kB +0.03% +14 B 🔺
@sentry/node 163.43 kB +0.01% +13 B 🔺
@sentry/node - without tracing 72.29 kB +0.03% +19 B 🔺
@sentry/aws-serverless 106.96 kB +0.02% +11 B 🔺
@sentry/cloudflare (withSentry) - minified 168.38 kB - -
@sentry/cloudflare (withSentry) 424.9 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.

Comment thread packages/node-core/src/integrations/systemError.ts
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 5d6a696. Configure here.

value: originalGetSystemErrorMap,
configurable: true,
writable: true,
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Test mock redefines module namespace

Medium Severity

util is an ESM module namespace for node:util, whose exports are non-configurable in Vitest’s Node environment. Redefining getSystemErrorMap with Object.defineProperty throws before assertions run, so the new regression tests fail instead of exercising the guard.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 5d6a696. Configure here.

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.

3 participants