Repository navigation
Conversation
… parser closures Follows up on angular#71904 with two targeted hardening fixes: 1. In `HybridCompiler.invalidateStaleFileAnalysis`, drop the `existing.boundFingerprint !== undefined` guard when comparing `existing.boundFingerprint !== nextFingerprint` so un-fingerprinted cache entries (for example from a direct `processFileSync` call) clear stale `parsedTemplates`, `preparedTcbData`, and `tcb` before stamping a newly computed fingerprint. Also clear `fileAnalysis.tcb` in `populateBoundData` whenever `preparedTcbData` is recomputed so subsequent `getTcbForFile` lookups do not return stale TCB code. 2. In `parseComponentTemplate`, isolate the lazy `diagNodes` parser closures into `createInlineDiagParser` and `createExternalDiagParser` so external/indirect templates do not capture the containing TypeScript file's `content` or `ComponentMetadata`, and clear the parser closure reference inside `defineLazyDiagNodes` once `diagNodes` is evaluated.
mattrbeck
force-pushed
the
fix/ngp-lazy-diag-cache-invalidation
branch
from
November 10, 2026 23:33
65d724c to
4eb2d46
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Follows up on #71904:
HybridCompiler.invalidateStaleFileAnalysis, movingexisting.boundFingerprint = nextFingerprintoutside the clearingifblock while keepingexisting.boundFingerprint !== undefined && existing.boundFingerprint !== nextFingerprintallows an un-fingerprintedfileCacheentry (boundFingerprint === undefined, such as one populated by a directprocessFileSynccall) to be stamped with a validboundFingerprintwithout clearing staleparsedTemplates,preparedTcbData, ortcbwhen a dependency's<ng-content>selectors change. Similarly,populateBoundDatadid not resetfileAnalysis.tcb, leaving stale TCB text forgetTcbForFilewhen re-binding an un-fingerprinted entry.parseComponentTemplate, the lazydiagNodesgetter sharedparseComponentTemplate's closure context, keeping the containing.tsfilecontent,ComponentMetadata, and parse options alive on cachedParsedComponentTemplateentries even for external templates and even afterdiagNodeshad already been evaluated.Issue Number: N/A
What is the new behavior?
HybridCompiler.invalidateStaleFileAnalysiscomparesexisting.boundFingerprint !== nextFingerprintdirectly so transitioning fromundefinedto a computed fingerprint clears stale cached state before stampingnextFingerprint(while keeping(undefined, undefined)intact), andpopulateBoundDataclearsfileAnalysis.tcb = undefinedwheneverpreparedTcbDatais recomputed.parseComponentTemplateisolates the lazydiagNodesparser closures intocreateInlineDiagParserandcreateExternalDiagParser(avoiding capturingComponentMetadata, and avoiding capturing.tscontentfor external/indirect templates) anddefineLazyDiagNodesclears the parser closure reference oncediagNodesis evaluated.Does this PR introduce a breaking change?
Other information