Describe
ESbuild leaks memory when cancelling rebuild, if done rapidly.
Repro
node main.ts -> Check Resource Manager
esbuild_cancel_leak.zip
import * as esbuild from 'esbuild';
const _ctx = await esbuild.context({
entryPoints: ['./content.ts'],
format: 'esm',
bundle: true,
write: false,
outfile: 'main',
});
const fn = async () => {
await _ctx.cancel();
_ctx.rebuild().catch(() => {});
};
for (let i = 0; 1_000_000 > i; i++) {
await fn();
}