Skip to content

Commit 56052eb

Browse files
committed
refactor: wip
1 parent 429fae3 commit 56052eb

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

packages/utils/src/lib/profiler/profiler.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import process from 'node:process';
22
import { threadId } from 'node:worker_threads';
33
import { isEnvVarEnabled } from '../env.js';
44
import { subscribeProcessExit } from '../exit-process.js';
5-
import type { TraceEvent } from '../trace-file.type';
65
import {
76
type ActionTrackConfigs,
87
type MeasureCtxOptions,
@@ -19,6 +18,7 @@ import type {
1918
EntryMeta,
2019
} from '../user-timing-extensibility-api.type.js';
2120
import { 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

260260
export 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

Comments
 (0)