You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Run first with 1.1.45+196621f25, then again with e.g. 1.2.0-canary.43+5819fe49a and compare the error object:
import{promisesasfs}from'node:fs'// create erroneous css fileconstfilename='test.css'awaitfs.writeFile(filename,'body margin: 0 }')try{// buildconstresult=awaitBun.build({entrypoints: [filename],minify: true,experimentalCss: true})// on build failure: is run until at least 1.1.45+196621f25, not run on 1.2.0-canary.43+5819fe49aif(!result.success){console.log('Manual throw:')throwresult.logs[0]}// do sth. with result, not relevant here}catch(e){console.error(e)console.log('---')console.error('Error Object:',JSON.stringify(e,null,2))// cleanupawaitfs.rm(filename,{force: true})}
This errors with the following error in both versions (as expected):
error: Unexpectedendofinputat/.../test.css:1:17
Which is correct and expected, but the error data I get is different.
What is the expected behavior?
Having an error object with details about the build error
the new behavior is intentionally throwing an AggregateError, see https://bun.sh/docs/bundler#logs-and-errors. This change was made after seeing most users forget to handle success: false, or worse forget to await the promise at all.
However, I did not check that JSON.stringify actually works, to which it seems to not work. We should fix that.
Maybe you can iterate and read errors individually with e.errors (array of message)
What version of Bun is running?
1.2.0-canary.43+5819fe49a
What platform is your computer?
Linux 6.12.9-200.fc41.x86_64 x86_64 unknown
What steps can reproduce the bug?
Run first with
1.1.45+196621f25
, then again with e.g.1.2.0-canary.43+5819fe49a
and compare the error object:This errors with the following error in both versions (as expected):
Which is correct and expected, but the error data I get is different.
What is the expected behavior?
Having an error object with details about the build error
(looks like the following in
1.1.45+196621f25
)something like:
What do you see instead?
no error object
(looks like the following in
1.2.0-canary.43+5819fe49a
)Additional information
In previous versions, the
Bun.build
command returned asuccess: false
key on the result object, and thelogs
property contained error information.The new variant throws an error directly, but has no error information attached.
I don't really care, how this gets handled, as long, as I get appropriate error data, that can be processed in JS :)
The text was updated successfully, but these errors were encountered: