Sentry.init hangs after compiling program to a binary using Bun, Commander.js, TypeScript. Consequently, nothing is captured by Sentry
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
- Start a bun typescript project
-
bun i @sentry/bun -
bun i commander - 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();
- Compile the program to a binary with:
bun build ./index.ts --compile --outfile cli --target=bun - 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
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.
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 🥀