Skip to content

Commit 9d848af

Browse files
fix
1 parent b98de32 commit 9d848af

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
@@ -923,40 +923,36 @@ export class McpContext implements Context {
923923
() => {
924924
/* noop */
925925
},
926-
import.meta.resolve('../third_party/devtools-heap-snapshot-worker.js'),
926+
import.meta.resolve('./third_party/devtools-heap-snapshot-worker.js'),
927927
);
928928

929929
const absolutePath = path.resolve(heapsnapshotPath);
930930

931-
try {
932-
const {promise: snapshotPromise, resolve: resolveSnapshot} =
933-
Promise.withResolvers<DevTools.HeapSnapshotModel.HeapSnapshotProxy.HeapSnapshotProxy>();
934-
935-
const loaderProxy = workerProxy.createLoader(
936-
1,
937-
(
938-
snapshotProxy: DevTools.HeapSnapshotModel.HeapSnapshotProxy.HeapSnapshotProxy,
939-
) => {
940-
resolveSnapshot(snapshotProxy);
941-
},
942-
);
931+
const {promise: snapshotPromise, resolve: resolveSnapshot} =
932+
Promise.withResolvers<DevTools.HeapSnapshotModel.HeapSnapshotProxy.HeapSnapshotProxy>();
943933

944-
const fileStream = fsSync.createReadStream(absolutePath, {
945-
encoding: 'utf-8',
946-
highWaterMark: 1024 * 1024,
947-
});
934+
const loaderProxy = workerProxy.createLoader(1, snapshotProxy => {
935+
resolveSnapshot(snapshotProxy);
936+
});
948937

949-
for await (const chunk of fileStream) {
950-
await loaderProxy.write(chunk);
951-
}
938+
const fileStream = fsSync.createReadStream(absolutePath, {
939+
encoding: 'utf-8',
940+
highWaterMark: 1024 * 1024,
941+
});
952942

953-
await loaderProxy.close();
943+
for await (const chunk of fileStream) {
944+
await loaderProxy.write(chunk);
945+
}
954946

955-
const snapshot = await snapshotPromise;
947+
await loaderProxy.close();
956948

957-
return snapshot;
958-
} finally {
959-
workerProxy.dispose();
960-
}
949+
const snapshot = await snapshotPromise;
950+
951+
//TODO Figure ot how to dispose the workeProxy.
952+
// Also the snapshot methods hangs if the workerProxy is
953+
// duposed instead of throwing
954+
955+
// workerProxy.dispose();
956+
return snapshot;
961957
}
962958
}

0 commit comments

Comments
 (0)