@@ -2,7 +2,6 @@ import process from 'node:process';
22import { threadId } from 'node:worker_threads' ;
33import { isEnvVarEnabled } from '../env.js' ;
44import { subscribeProcessExit } from '../exit-process.js' ;
5- import type { TraceEvent } from '../trace-file.type' ;
65import {
76 type ActionTrackConfigs ,
87 type MeasureCtxOptions ,
@@ -19,6 +18,7 @@ import type {
1918 EntryMeta ,
2019} from '../user-timing-extensibility-api.type.js' ;
2120import { PROFILER_ENABLED_ENV_VAR } from './constants.js' ;
21+ import { type TraceEvent } from './trace-file.type.js' ;
2222
2323/**
2424 * Generates a unique profiler ID based on performance time origin, process ID, thread ID, and instance count.
@@ -258,7 +258,7 @@ export type NodeJsProfilerOptions<T extends ActionTrackConfigs> =
258258 } ;
259259
260260export class NodeJsProfiler < T extends ActionTrackConfigs > extends Profiler < T > {
261- #exitHandlerSubscribscription : null | ( ( ) => void ) = null ;
261+ #exitHandlerSubscription : null | ( ( ) => void ) = null ;
262262 protected sink : WalSink | null = null ;
263263
264264 constructor ( options : NodeJsProfilerOptions < T > ) {
@@ -272,7 +272,7 @@ export class NodeJsProfiler<T extends ActionTrackConfigs> extends Profiler<T> {
272272 close : ( ) => void 0 ,
273273 isClosed : ( ) => false ,
274274 } ;
275- this . #exitHandlerSubscribscription = this . subscribeProcessExit ( ) ;
275+ this . #exitHandlerSubscription = this . subscribeProcessExit ( ) ;
276276 }
277277
278278 /**
@@ -321,6 +321,8 @@ export class NodeJsProfiler<T extends ActionTrackConfigs> extends Profiler<T> {
321321 return ;
322322 }
323323 this . setEnabled ( false ) ;
324- this . #exitHandlerSubscribscription?.( ) ;
324+ this . #exitHandlerSubscription?.( ) ;
325+ this . #exitHandlerSubscription = null ;
326+ this . sink ?. close ( ) ;
325327 }
326328}
0 commit comments