File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -29,6 +29,18 @@ console.log = (...args: unknown[]) =>
2929console . warn = ( ...args : unknown [ ] ) =>
3030 process . stderr . write ( args . join ( ' ' ) + '\n' ) ;
3131
32+ // Catch errors from microtasks/unhandled rejections that would otherwise cause
33+ // a silent exit with code 0 on some Bun versions (e.g. when img.la() throws in
34+ // a queueMicrotask callback because WebGL is unavailable on Linux CI).
35+ process . on ( 'uncaughtException' , ( err ) => {
36+ process . stderr . write ( `uncaughtException: ${ err . stack ?? err . message } \n` ) ;
37+ process . exit ( 1 ) ;
38+ } ) ;
39+ process . on ( 'unhandledRejection' , ( reason ) => {
40+ process . stderr . write ( `unhandledRejection: ${ reason } \n` ) ;
41+ process . exit ( 1 ) ;
42+ } ) ;
43+
3244if ( ! input ) {
3345 process . stderr . write ( 'Usage: bun rive-extract-schema.ts <path-or-url>\n' ) ;
3446 process . exit ( 1 ) ;
@@ -50,12 +62,13 @@ async function main() {
5062
5163 // Stub image loading: call la() (the "loaded" callback) immediately so
5264 // runtime.load() resolves without waiting for CDN asset fetches.
65+ // Guard against null return when WebGL is unavailable (headless Linux).
5366 const origMRI = ( runtime . renderFactory as any ) . makeRenderImage . bind (
5467 runtime . renderFactory
5568 ) ;
5669 ( runtime . renderFactory as any ) . makeRenderImage = function ( ) {
5770 const img = origMRI ( ) ;
58- queueMicrotask ( ( ) => img . la ( ) ) ;
71+ if ( img ) queueMicrotask ( ( ) => img . la ?. ( ) ) ;
5972 return img ;
6073 } ;
6174
You can’t perform that action at this time.
0 commit comments