question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use of `any` in captureException Typing Leads to Errors Throughout the SDK

See original GitHub issue

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which package are you using?

@sentry/node

SDK Version

7.13.0

Framework Version

No response

Link to Sentry event

https://sentry.io/organizations/openbase/issues/3600440747/?alert_rule_id=10952756&alert_timestamp=1663519962319&alert_type=email&project=6368396&referrer=alert_email

Steps to Reproduce

this.hub = getCurrentHub();
this.hub?.captureException(void 0);

Expected Result

Well, this shouldn’t be possible.

I would expect that @sentry/hub would be catching the fact that the value is invalid.

Actual Result

An error is thrown, as described here: https://github.com/getsentry/sentry-javascript/issues/5622#issuecomment-1250343554

I would really expect the sentry packages to have better error handling, especially considered how they’ve been made interdependent. Instead, we get vague error messages that we have to debug ourselves, rather than package-level error handling, custom errors thrown with proper codes.

This also bleeds into this change: https://github.com/getsentry/sentry-javascript/pull/5497/files#r973748050, where _handler was checked but the value of the event was never verified. A curious oversight if there were concerns about version conflicts and unknown sources of error.

This line: https://github.com/getsentry/sentry-javascript/blob/9862a32899a41a3af9a5cd87c0d4a09a1d689e25/packages/types/src/hub.ts#L80 is the source of the troubles for both concerns. I’m not sure how this passed review given the number of things that hub interacts with. The use of any here is wholly incorrect and should at least filter to defined and not null. The problem is also pervasive for every definition of captureException including https://github.com/getsentry/sentry-javascript/blob/9862a32899a41a3af9a5cd87c0d4a09a1d689e25/packages/types/src/client.ts#L30

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
shellscapecommented, Sep 21, 2022

Your own test, as linked above, is the reproduction. Choosing to do nothing is simply lazy.

1reaction
lforstcommented, Sep 21, 2022

I’m going to unsubscribe from this issue

That is totally fine. If anybody else encounters this issue and can provide a reproduction example, ping us here and we will reopen! 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Exception on captureException() call · Issue #5622 - GitHub
Seems that Sentry SDK is not using NodeJS Crypto module but a polyfill ... Use of any in captureException Typing Leads to Errors...
Read more >
Usage | Sentry Documentation
Capturing Errors You can use captureException to manually report errors: The recommended usage pattern, though, is to run your entire program inside a...
Read more >
PHP SDK not sending errors to Sentry when invoked from IBM ...
When I test the action handler from my local environment(NGINX/PHP Docker containers) the errors are being sent to Sentry. But when I try...
Read more >
sentry - Go Packages
Package sentry is the official Sentry SDK for Go. Use it to report errors and track application performance through distributed tracing. For more...
Read more >
Public API | APM .NET Agent Reference [1.x] - Elastic
If your application communicates over a protocol that is not supported by the ... If no transaction is active, the error will still...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found