Skip to content
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

fix(node): Ensure that self._handler exists before calling it in LinkedErrors #5497

Merged
merged 1 commit into from
Aug 1, 2022

Conversation

Lms24
Copy link
Member

@Lms24 Lms24 commented Jul 29, 2022

This patch brings back a check for self._handler in the global event processor of the LinkedErrors integration for Node.
The check was removed in #4902 but apparently it is still necessary.

fixes #5493

@github-actions
Copy link
Contributor

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 19.36 KB (0%)
@sentry/browser - ES5 CDN Bundle (minified) 59.92 KB (0%)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 17.93 KB (+0.03% 🔺)
@sentry/browser - ES6 CDN Bundle (minified) 52.79 KB (0%)
@sentry/browser - Webpack (gzipped + minified) 19.69 KB (0%)
@sentry/browser - Webpack (minified) 64.13 KB (0%)
@sentry/react - Webpack (gzipped + minified) 19.71 KB (0%)
@sentry/nextjs Client - Webpack (gzipped + minified) 44.11 KB (0%)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 25.76 KB (0%)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 24.01 KB (0%)

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.

From the linked Sentry error, it seems the event has no breadcrumbs. This leads me to believe that this error is happening right at the start so for some reason, very mysterious.

@@ -47,7 +47,7 @@ export class LinkedErrors implements Integration {
const hub = getCurrentHub();
const self = hub.getIntegration(LinkedErrors);
const client = hub.getClient<NodeClient>();
if (client && self) {
if (client && self && self._handler && typeof self._handler === 'function') {
await self._handler(client.getOptions().stackParser, event, hint);
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand how self._handler could ever error, but we gotta do this to unblock

sad cat thumbs up

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't understand how this happens either but this should fix it for now. Will try to investigate this more on Monday. Since we're cutting a patch on Monday, I'll leave this open till then

Copy link
Member

Choose a reason for hiding this comment

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

If I had to guess it's due to multiple @sentry/nodes being installed - maybe through transitive deps?

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree that a version conflict might cause this. Apart from that I don't see how this method would not exist while the class instance obviously does exist.

Copy link
Member Author

Choose a reason for hiding this comment

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

Merging this for now as I think the check doesn't hurt us

Copy link

@public public Aug 1, 2022

Choose a reason for hiding this comment

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

I checked out package-lock.json when we had 7.8.0 installed and can't see any references to other versions of sentry/node in there. Happy to share the full file if you think it would be helpful.

@Lms24 Lms24 merged commit 101a023 into master Aug 1, 2022
@Lms24 Lms24 deleted the lms-fix-self-handler branch August 1, 2022 09:25
Lms24 added a commit that referenced this pull request Aug 1, 2022
@Lms24 Lms24 self-assigned this Aug 1, 2022
@@ -47,7 +47,7 @@ export class LinkedErrors implements Integration {
const hub = getCurrentHub();
const self = hub.getIntegration(LinkedErrors);
const client = hub.getClient<NodeClient>();
if (client && self) {
if (client && self && self._handler && typeof self._handler === 'function') {
Copy link

@shellscape shellscape Sep 18, 2022

Choose a reason for hiding this comment

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

@Lms24 @AbhiPrasad this should have included a check that event was truthy and an object and if not, returned, since calling _handler with an invalid event object does the same. see: #5622 (comment)

The package should also warn to console when something. like this happens, or at least output to a debug channel that can be enabled.

If the package had some better internal error handling and better debug logging, I could have narrowed this down further. Alas.

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.

TypeError: self._handler is not a function in @sentry/node 7.8.0
5 participants