File tree Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -6,10 +6,24 @@ function tryLoadLZ4Module(): LZ4Module | undefined {
66 try {
77 return require ( 'lz4' ) ; // eslint-disable-line global-require
88 } catch ( err ) {
9- const isModuleNotFoundError = err instanceof Error && 'code' in err && err . code === 'MODULE_NOT_FOUND' ;
10- if ( ! isModuleNotFoundError ) {
11- throw err ;
9+ if ( ! ( err instanceof Error ) || ! ( 'code' in err ) ) {
10+ console . warn ( 'Unexpected error loading LZ4 module: Invalid error object' , err ) ;
11+ return undefined ;
1212 }
13+
14+ if ( err . code === 'MODULE_NOT_FOUND' ) {
15+ console . warn ( 'LZ4 module not installed: Missing dependency' , err ) ;
16+ return undefined ;
17+ }
18+
19+ if ( err . code === 'ERR_DLOPEN_FAILED' ) {
20+ console . warn ( 'LZ4 native module failed to load: Architecture or version mismatch' , err ) ;
21+ return undefined ;
22+ }
23+
24+ // If it's not a known error, return undefined
25+ console . warn ( 'Unknown error loading LZ4 module: Unhandled error code' , err ) ;
26+ return undefined ;
1327 }
1428}
1529
You can’t perform that action at this time.
0 commit comments