Skip to content

feat(node): Capture SystemError context and remove paths from message #17331

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

timfish
Copy link
Collaborator

@timfish timfish commented Aug 5, 2025

resolves #17332

Node.js has a SystemError error class.

This error type contains numerous properties which can be useful for debugging but it also includes many of them in the error message which stops fingerprinting from grouping these errors.

This PR adds a default enabled integration that copies the error properties to a new context and strips paths from the error message.

If the top-level sendDefaultPii is not enabled, the path and dest properties will not be included.

cursor[bot]

This comment was marked as outdated.

for (const exception of event.exception?.values || []) {
if (exception.value) {
if (error.path && exception.value.includes(error.path)) {
exception.value = exception.value.replace(`'${error.path}'`, '').trim();
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we should expose an integration option to control this replacement as well

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ideally I would have used util.getSystemErrorMessage(err) to get the plain message without the paths but it was only added in Node v22

@@ -32,6 +32,7 @@ import { onUncaughtExceptionIntegration } from '../integrations/onuncaughtexcept
import { onUnhandledRejectionIntegration } from '../integrations/onunhandledrejection';
import { processSessionIntegration } from '../integrations/processSession';
import { INTEGRATION_NAME as SPOTLIGHT_INTEGRATION_NAME, spotlightIntegration } from '../integrations/spotlight';
import { systemErrorIntegration } from '../integrations/systemError';
Copy link
Member

Choose a reason for hiding this comment

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

we'll have to export this from all of our node packages as well

Copy link
Contributor

github-actions bot commented Aug 5, 2025

size-limit report 📦

Path Size % Change Change
@sentry/browser 24.11 kB -0.2% -46 B 🔽
@sentry/browser - with treeshaking flags 22.68 kB -0.23% -52 B 🔽
@sentry/browser (incl. Tracing) 39.83 kB -0.12% -44 B 🔽
@sentry/browser (incl. Tracing, Replay) 77.92 kB -0.09% -69 B 🔽
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 67.77 kB -0.1% -62 B 🔽
@sentry/browser (incl. Tracing, Replay with Canvas) 82.63 kB -0.08% -61 B 🔽
@sentry/browser (incl. Tracing, Replay, Feedback) 94.73 kB -0.07% -64 B 🔽
@sentry/browser (incl. Feedback) 40.77 kB -0.15% -61 B 🔽
@sentry/browser (incl. sendFeedback) 28.77 kB -0.13% -36 B 🔽
@sentry/browser (incl. FeedbackAsync) 33.66 kB -0.14% -46 B 🔽
@sentry/react 25.83 kB -0.19% -49 B 🔽
@sentry/react (incl. Tracing) 41.8 kB -0.15% -62 B 🔽
@sentry/vue 28.59 kB -0.2% -55 B 🔽
@sentry/vue (incl. Tracing) 41.64 kB -0.13% -52 B 🔽
@sentry/svelte 24.14 kB -0.19% -44 B 🔽
CDN Bundle 25.62 kB -0.18% -46 B 🔽
CDN Bundle (incl. Tracing) 39.72 kB -0.1% -39 B 🔽
CDN Bundle (incl. Tracing, Replay) 75.77 kB -0.08% -54 B 🔽
CDN Bundle (incl. Tracing, Replay, Feedback) 81.19 kB -0.1% -81 B 🔽
CDN Bundle - uncompressed 74.89 kB -0.1% -70 B 🔽
CDN Bundle (incl. Tracing) - uncompressed 117.52 kB -0.06% -70 B 🔽
CDN Bundle (incl. Tracing, Replay) - uncompressed 231.78 kB -0.04% -92 B 🔽
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 244.38 kB -0.04% -92 B 🔽
@sentry/nextjs (client) 43.83 kB -0.13% -57 B 🔽
@sentry/sveltekit (client) 40.27 kB -0.13% -51 B 🔽
@sentry/node-core 47.97 kB +0.34% +162 B 🔺
⛔️ @sentry/node (max: 147 kB) 147 kB +0.12% +173 B 🔺
@sentry/node - without tracing 92.21 kB +0.19% +169 B 🔺
@sentry/aws-serverless 103.64 kB +0.17% +166 B 🔺

View base workflow run

@mydea mydea changed the title feat(node) Capture SystemError context and remove paths from message feat(node): Capture SystemError context and remove paths from message Aug 6, 2025
Copy link
Member

@AbhiPrasad AbhiPrasad left a comment

Choose a reason for hiding this comment

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

Think we are good to go after we fix bun

…om:getsentry/sentry-javascript into timfish/feat/node-system-error-integration
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.

Add SystemError integration in Node SDK
2 participants