File tree Expand file tree Collapse file tree 3 files changed +27
-6
lines changed
Expand file tree Collapse file tree 3 files changed +27
-6
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,12 @@ process.title = `Kit Idle - Main Script`
4242configEnv ( )
4343
4444process . once ( "beforeExit" , ( ) => {
45- send ( Channel . BEFORE_EXIT )
45+ try {
46+ console . warn ( '[app-exit-diag] app-index BEFORE_EXIT sending' )
47+ send ( Channel . BEFORE_EXIT )
48+ } catch ( e ) {
49+ console . warn ( '[app-exit-diag] app-index send BEFORE_EXIT failed:' , ( e as any ) ?. message || e )
50+ }
4651} )
4752
4853log (
Original file line number Diff line number Diff line change @@ -128,11 +128,22 @@ configEnv()
128128process . title = `Kit - ${ path . basename ( script ) } `
129129
130130process . once ( 'beforeExit' , ( ) => {
131- if ( global ?. trace ?. flush ) {
132- global . trace . flush ( )
133- global . trace = null
131+ // Emit BEFORE_EXIT before tearing down tracing to avoid null deref
132+ try {
133+ console . warn ( '[app-exit-diag] app-prompt BEFORE_EXIT sending' )
134+ send ( Channel . BEFORE_EXIT )
135+ } catch ( e ) {
136+ console . warn ( '[app-exit-diag] send BEFORE_EXIT failed:' , ( e as any ) ?. message || e )
137+ }
138+ try {
139+ if ( global ?. trace ?. flush ) {
140+ global . trace . flush ( )
141+ }
142+ } catch ( e ) {
143+ console . warn ( '[app-exit-diag] trace.flush failed:' , ( e as any ) ?. message || e )
144+ } finally {
145+ try { ( global as any ) . trace = null } catch { }
134146 }
135- send ( Channel . BEFORE_EXIT )
136147} )
137148
138149performance . mark ( 'run' )
Original file line number Diff line number Diff line change @@ -24,7 +24,12 @@ let script = await arg("Path to script:")
2424process . title = path . basename ( script )
2525
2626process . once ( "beforeExit" , ( ) => {
27- send ( Channel . BEFORE_EXIT )
27+ try {
28+ console . warn ( '[app-exit-diag] app BEFORE_EXIT sending' )
29+ send ( Channel . BEFORE_EXIT )
30+ } catch ( e ) {
31+ console . warn ( '[app-exit-diag] app send BEFORE_EXIT failed:' , ( e as any ) ?. message || e )
32+ }
2833} )
2934
3035await run ( script )
You can’t perform that action at this time.
0 commit comments