core icon indicating copy to clipboard operation
core copied to clipboard

bun with oclif not catching unhandled exceptions

Open codegod100 opened this issue 1 year ago • 4 comments

Describe the bug while using bun oclif doesn't catch unhandled exceptions

To Reproduce Steps to reproduce the behavior:

  1. change shebang to #!/usr/bin/env bun
  2. throw unhandled exception
  3. no error output

Expected behavior stack trace of exception

Environment (please complete the following information):

  • OS & version: debian 12
  • Shell/terminal & version: vscode

codegod100 avatar May 25 '24 04:05 codegod100

@codegod100 Can you create a repository that replicates the issue? Thanks

mdonnalley avatar May 31 '24 18:05 mdonnalley

Good news: I get the same result regardless of whether I use bun or node. Bad news: the result doesn't include the stacktrace.

Replication steps:

  1. follow tutorial with Node LTS
  2. add throw new Error("testing"); to run in src/commands/hello/world.ts
  3. npm run build
  4. /bin/run.js hello world

But maybe the lack of stacktrace is intentional? Not sure. I tried setting DEBUG=* (see https://oclif.io/docs/debugging) but nothing changed when I ran it again

calebAtIspot avatar Jun 05 '24 21:06 calebAtIspot

@calebAtIspot I followed your steps and I see the stacktrace in the debug output:

    Error: testing
  oclif:error Error: testing
  oclif:error     at <anonymous> (~/code/gh1086/src/commands/hello/world.ts:16:29)
  oclif:error     at run (~/code/gh1086/src/commands/hello/world.ts:14:15)
  oclif:error     at <anonymous> (~/code/gh1086/node_modules/@oclif/core/lib/command.js:228:32)
  oclif:error     at processTicksAndRejections (:12:39) +0ms

These are the steps I followed: node version: 20.31.1 bun version: 1.1.12 oclif version: 4.13.5

  • oclif generate gh1086 --yes
  • change shebang in bin/run.js to #!/usr/bin/env bun
  • add throw new Error("testing"); to run in src/commands/hello/world.ts
  • npm run build
  • DEBUG=* bin/run.js hello world

What am I missing?

mdonnalley avatar Jun 10 '24 19:06 mdonnalley

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Jul 11 '24 02:07 github-actions[bot]