sentry-javascript icon indicating copy to clipboard operation
sentry-javascript copied to clipboard

Sentry.init hangs after compiling program to a binary using Bun, Commander.js, TypeScript. Consequently, nothing is captured by Sentry

Open slagcode opened this issue 1 year ago • 2 comments

Is there an existing issue for this?

  • [X] I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
  • [X] I have reviewed the documentation https://docs.sentry.io/
  • [X] I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/bun

SDK Version

7.107.0

Framework Version

7.107.0

Link to Sentry event

No response

SDK Setup

    Sentry.init({
        dsn: "https://dsngoeshere",
        tracesSampleRate: 1.0
    });

Steps to Reproduce

  1. Start a bun typescript project
  2. bun i @sentry/bun
  3. bun i commander
  4. Add the following to index.ts
// index.ts

import { Command } from 'commander';

export const program = new Command();

Sentry.init({
    dsn: "dsngoeshere",
    // Performance Monitoring
    tracesSampleRate: 1.0, // Capture 100% of the transactions
});

Sentry.captureException(new Error('My first Sentry error!'));

program
    .command('bug')
    .description('Report a bug')
    .action(() => console.log('This is a bug!'))


program.parse();
  1. Compile the program to a binary with: bun build ./index.ts --compile --outfile cli --target=bun
  2. Run the binary ./cli bug

Expected Result

An error to be captured in Sentry.

Actual Result

Nothing gets captured, and the CLI hangs on the init step.

Edit: I've found that the command actually works when running with bun directly: bun index.ts bug.

But it does not work (it hangs) when building then running the compiled binary like so:

bun build ./index.ts --compile --outfile cli --target=bun
./cli bug

slagcode avatar Mar 17 '24 16:03 slagcode

Hey @slagcode thx for writing in! I don't think we ever tested the SDK in a compiled binary (TIL that this is possible with Bun) so chances are that something is going wrong 😅

Would you mind enabling debug logging by setting debug: true in your Sentry.init call? Let's see if we get some logs before the execution hangs so that we can narrow it down.

Lms24 avatar Mar 18 '24 12:03 Lms24

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you remove the label Waiting for: Community, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

getsantry[bot] avatar May 16 '24 07:05 getsantry[bot]