bun
bun copied to clipboard
Erorrs caught within a try/catch in wiptest are being printed to console (sometimes)
What version of Bun is running?
0.3.0 (canary)
What platform is your computer?
Darwin 21.6.0 Darwin Kernel Version 21.6.0: Mon Aug 22 20:17:10 PDT 2022; root:xnu-8020.140.49~2/RELEASE_X86_64 x86_64 i386
What steps can reproduce the bug?
- Download repo: https://github.com/dominicporteous/bun-commander
- Run command:
bun wiptest tests/options.version.test.js
You can see from the output, that the tests do pass as expected but the console is polluted with errors which are being handled by the try/catch blocks e.g.
✓ .version > when have .version+version and specify version then command called
11 | * @param {string} code an id string representing the error
12 | * @param {string} message human-readable description of the error
13 | * @constructor
14 | */
15 | constructor(exitCode, code, message) {
16 | super(message);
^
CommanderError: 1.2.3
code: "commander.version"
at new CommanderError (/Users/dom/Github/bun-commander/lib/error.js:16:4)
at _exit (/Users/dom/Github/bun-commander/lib/command.js:459:25)
at /Users/dom/Github/bun-commander/lib/command.js:1810:6
at parseOptions (/Users/dom/Github/bun-commander/lib/command.js:1464:12)
at _parseCommand (/Users/dom/Github/bun-commander/lib/command.js:1241:19)
at parse (/Users/dom/Github/bun-commander/lib/command.js:900:4)
at /Users/dom/Github/bun-commander/tests/options.version.test.js:183:8
I have verified that there are no calls in the code path which would output this to the console. (e.g. console.log/error or Bun.write)
How often does it reproduce? Is there a required condition?
Occurs every time
What is the expected behavior?
The exception should not be printed as it is being handled by the catch block
What do you see instead?
The error is caught correctly, but the error is being printed to the console.
Additional information
No response
Thanks for filing
No longer reproducible as of Bun v1.0.7.
❯ bun test tests/options.version.test.js
bun test v1.0.7 (fa1bbec0)
tests/options.version.test.js:
✓ .version > when no .version and specify --version then unknown option error [2.41ms]
✓ .version > when no .version then helpInformation does not include version [0.65ms]
✓ .version > when specify default short flag then display version [0.86ms]
✓ .version > when specify default long flag then display version [0.15ms]
✓ .version > when default .version then helpInformation includes default version help [0.12ms]
✓ .version > when specify custom short flag then display version [0.14ms]
✓ .version > when specify just custom short flag then display version [0.10ms]
✓ .version > when specify custom long flag then display version [0.10ms]
✓ .version > when specify just custom long flag then display version [0.08ms]
✓ .version > when custom .version then helpInformation includes custom version help [0.08ms]
✓ .version > when have .version+version and specify version then command called [0.42ms]
✓ .version > when have .version+version and specify --version then version displayed [0.08ms]
✓ .version > when specify version then can get version [0.04ms]
13 pass
0 fail
21 expect() calls
Ran 13 tests across 1 files. [66.00ms]
If you still run into this issue, please feel free to re-open this issue.