Skip to content

Commit 13d2f59

Browse files
fix
1 parent 8f2dc7b commit 13d2f59

1 file changed

Lines changed: 22 additions & 26 deletions

File tree

src/McpContext.ts

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -915,40 +915,36 @@ export class McpContext implements Context {
915915
() => {
916916
/* noop */
917917
},
918-
import.meta.resolve('../third_party/devtools-heap-snapshot-worker.js'),
918+
import.meta.resolve('./third_party/devtools-heap-snapshot-worker.js'),
919919
);
920920

921921
const absolutePath = path.resolve(heapsnapshotPath);
922922

923-
try {
924-
const {promise: snapshotPromise, resolve: resolveSnapshot} =
925-
Promise.withResolvers<DevTools.HeapSnapshotModel.HeapSnapshotProxy.HeapSnapshotProxy>();
926-
927-
const loaderProxy = workerProxy.createLoader(
928-
1,
929-
(
930-
snapshotProxy: DevTools.HeapSnapshotModel.HeapSnapshotProxy.HeapSnapshotProxy,
931-
) => {
932-
resolveSnapshot(snapshotProxy);
933-
},
934-
);
923+
const {promise: snapshotPromise, resolve: resolveSnapshot} =
924+
Promise.withResolvers<DevTools.HeapSnapshotModel.HeapSnapshotProxy.HeapSnapshotProxy>();
935925

936-
const fileStream = fsSync.createReadStream(absolutePath, {
937-
encoding: 'utf-8',
938-
highWaterMark: 1024 * 1024,
939-
});
926+
const loaderProxy = workerProxy.createLoader(1, snapshotProxy => {
927+
resolveSnapshot(snapshotProxy);
928+
});
940929

941-
for await (const chunk of fileStream) {
942-
await loaderProxy.write(chunk);
943-
}
930+
const fileStream = fsSync.createReadStream(absolutePath, {
931+
encoding: 'utf-8',
932+
highWaterMark: 1024 * 1024,
933+
});
944934

945-
await loaderProxy.close();
935+
for await (const chunk of fileStream) {
936+
await loaderProxy.write(chunk);
937+
}
946938

947-
const snapshot = await snapshotPromise;
939+
await loaderProxy.close();
948940

949-
return snapshot;
950-
} finally {
951-
workerProxy.dispose();
952-
}
941+
const snapshot = await snapshotPromise;
942+
943+
//TODO Figure ot how to dispose the workeProxy.
944+
// Also the snapshot methods hangs if the workerProxy is
945+
// duposed instead of throwing
946+
947+
// workerProxy.dispose();
948+
return snapshot;
953949
}
954950
}

0 commit comments

Comments
 (0)