File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ import {
3535 */
3636const PERF_ENABLED = ( process . env as Readonly < { REZI_PERF ?: string } > ) . REZI_PERF === "1" ;
3737const ZR_ERR_LIMIT = - 3 ;
38+ const IS_BUN_RUNTIME = typeof ( globalThis as { Bun ?: unknown } ) . Bun !== "undefined" ;
3839type PerfSample = { phase : string ; durationMs : number } ;
3940const perfSamples : PerfSample [ ] = [ ] ;
4041const PERF_MAX_SAMPLES = 1024 ;
@@ -617,6 +618,13 @@ function shutdownNow(): void {
617618
618619 // Let worker thread exit naturally once handles are cleared.
619620 if ( parentPort !== null ) parentPort . close ( ) ;
621+ // Bun worker_threads can keep the worker alive after parentPort.close().
622+ // Force a clean worker exit after sending shutdownComplete.
623+ if ( IS_BUN_RUNTIME ) {
624+ setImmediate ( ( ) => {
625+ process . exit ( 0 ) ;
626+ } ) ;
627+ }
620628}
621629
622630function tick ( ) : void {
You can’t perform that action at this time.
0 commit comments