Skip to content

Commit 29cc52c

Browse files
committed
fix(#31973): Added JavaScriptTransformer close to dispose method
This change allows for awaiting the disposed plugin and added the missing close method of the JavaScript transformer to the onDispose. When the plugin is run multiple times on different projects/bundles without proper closing it will result in a node heap corruption. This allows us to cleanup the build before we start a new one.
1 parent bf990dc commit 29cc52c

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

packages/angular/build/src/tools/esbuild/angular/compiler-plugin.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -588,11 +588,14 @@ export function createCompilerPlugin(
588588
logCumulativeDurations();
589589
});
590590

591-
build.onDispose(() => {
592-
sharedTSCompilationState?.dispose();
593-
void compilation.close?.();
594-
void cacheStore?.close();
595-
});
591+
build.onDispose(() => Promise.all(
592+
[
593+
compilation?.close?.(),
594+
cacheStore?.close(),
595+
javascriptTransformer?.close()
596+
].filter((p): p is Promise<void> => p !== undefined)
597+
).then(() => sharedTSCompilationState?.dispose())
598+
);
596599

597600
/**
598601
* Checks if the file has side-effects when `advancedOptimizations` is enabled.

0 commit comments

Comments
 (0)