File tree Expand file tree Collapse file tree
test/addons/worker-addon-exit Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+ const common = require ( '../../common' ) ;
3+ const { isMainThread, Worker } = require ( 'worker_threads' ) ;
4+
5+ if ( ! isMainThread ) {
6+ const addon = require ( `./build/${ common . buildType } /binding` ) ;
7+
8+
9+ // Create some garbage
10+ const arr = [ ] ;
11+ for ( let i = 0 ; i < 1e5 ; i ++ ) arr . push ( `${ i } ` . repeat ( 100 ) ) ;
12+
13+ new addon . MyObject ( 10 ) ;
14+
15+ // Should not segfault
16+ throw new Error ( 'exit' ) ;
17+ } else {
18+ const worker = new Worker ( __filename ) ;
19+ worker . on ( 'error' , common . mustCall ( ( ) => { } ) ) ;
20+ }
Original file line number Diff line number Diff line change @@ -11,5 +11,5 @@ if (!isMainThread) {
1111 throw new Error ( 'exit' ) ;
1212} else {
1313 const worker = new Worker ( __filename ) ;
14- worker . on ( 'error' , ( ) => { } ) ;
14+ worker . on ( 'error' , common . mustCall ( ( ) => { } ) ) ;
1515}
You can’t perform that action at this time.
0 commit comments