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

Get Sentry-like error reporting working #5091

Closed
4 tasks done
Jarred-Sumner opened this issue Sep 12, 2023 · 8 comments · Fixed by #10902
Closed
4 tasks done

Get Sentry-like error reporting working #5091

Jarred-Sumner opened this issue Sep 12, 2023 · 8 comments · Fixed by #10902
Assignees
Labels
atw tracking An umbrella issue for tracking big features

Comments

@Jarred-Sumner
Copy link
Collaborator

Jarred-Sumner commented Sep 12, 2023

https://nodejs.org/api/process.html#event-uncaughtexceptionmonitor

  • process.on("unhandledRejection", cb)
  • process.on("unhandledException", cb)
  • process.on("uncaughtExceptionMonitor", cb)
  • process.setUncaughtExceptionCaptureCallback(cb)

This lets Sentry get error reporting working.

Ideally, the fix would go here:

pub const UnhandledRejectionScope = struct {
ctx: ?*anyopaque = null,
onUnhandledRejection: *const OnUnhandledRejection = undefined,
count: usize = 0,
pub fn apply(this: *UnhandledRejectionScope, vm: *JSC.VirtualMachine) void {
vm.onUnhandledRejection = this.onUnhandledRejection;
vm.onUnhandledRejectionCtx = this.ctx;
vm.unhandled_error_counter = this.count;
}
};

We would add an unhandled rejection scope for either rejections or exceptions and have some way to distinguish between the two. This one would call into JS potentially for multiple handlers. The part that gets a little tricky is in unit tests where we rely on this behavior for expect().toThrow()

cc @dcramer

@Jarred-Sumner Jarred-Sumner added the tracking An umbrella issue for tracking big features label Sep 12, 2023
@paperdave paperdave added the atw label Sep 14, 2023
@HazAT
Copy link

HazAT commented Sep 18, 2023

We will release the Sentry SDK this week - Most things work (manually) once this lands we'll shoot out an update supporting it. Few users already asked for Sentry Bun SDK 😅

@AbhiPrasad
Copy link
Contributor

We just shipped https://www.npmjs.com/package/@sentry/bun as part of https://github.com/getsentry/sentry-javascript/releases/tag/7.70.0.

bun add @sentry/bun

@HazAT
Copy link

HazAT commented Sep 26, 2023

I don't want to spam here 😅 but with version 7.71.0 of the Sentry Bun SDK we wrap Bun.serve automatically getsentry/sentry-javascript#9080 capturing Errors and Transactions that happen during requests.

@colinricardo
Copy link

#7472 still seems to be an issue with:

- `@sentry/bun version 7.93.0`
- `bun version 1.0.20`

@GingerAdonis
Copy link

I'm aware that the team has lots of things to work on, but I'd like to say that this is likely a blocker for many to use Bun in production.

@ohbob

This comment was marked as duplicate.

@thecrabcode
Copy link

I agree with @GingerAdonis, this is very important for many devs. Do you guys have any estimates on when this could potentially be fixed?

HazAT added a commit to getsentry/sentry-javascript that referenced this issue May 10, 2024
Add support for global onUnhandled Error/Promise for Bun.

```javascript
import * as Sentry from "@sentry/bun";

Sentry.init({
    dsn: "DSN",
});

console.log("Hello via Bun!");

throw new Error('Unhandled Bun Sentry Error!');
```

<img width="1063" alt="image"
src="https://github.com/getsentry/sentry-javascript/assets/363802/fd90969f-82a4-4300-a67e-1ebb5cf540fa">

ref: oven-sh/bun#5091
HazAT added a commit to getsentry/sentry-javascript that referenced this issue May 10, 2024
Add support for global onUnhandled Error/Promise for Bun.

```javascript
import * as Sentry from "@sentry/bun";

Sentry.init({
    dsn: "DSN",
});

console.log("Hello via Bun!");

throw new Error('Unhandled Bun Sentry Error!');
```

<img width="1063" alt="image"
src="https://github.com/getsentry/sentry-javascript/assets/363802/fd90969f-82a4-4300-a67e-1ebb5cf540fa">

ref: oven-sh/bun#5091
@AbhiPrasad
Copy link
Contributor

AbhiPrasad commented May 15, 2024

In latest 7.x and 8.x versions of @sentry/bun we’ve added instrumentation to these global handlers to automatically capture errors and send them to Sentry. 8.0.0 also has a fix for performance monkey-patching, which means sentry performance monitoring should work in all cases with Bun!

Please reach out if something looks off, thanks for all the patience everyone!

https://docs.sentry.io/platforms/javascript/guides/bun

https://docs.sentry.io/platforms/javascript/guides/bun/migration/v7-to-v8

andreiborza pushed a commit to getsentry/sentry-javascript that referenced this issue May 16, 2024
Add support for global onUnhandled Error/Promise for Bun.

```javascript
import * as Sentry from "@sentry/bun";

Sentry.init({
    dsn: "DSN",
});

console.log("Hello via Bun!");

throw new Error('Unhandled Bun Sentry Error!');
```

<img width="1063" alt="image"
src="https://github.com/getsentry/sentry-javascript/assets/363802/fd90969f-82a4-4300-a67e-1ebb5cf540fa">

ref: oven-sh/bun#5091
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
atw tracking An umbrella issue for tracking big features
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants