From 61d817135e3235d5d49d1c5c312b2b8eb613fbbb Mon Sep 17 00:00:00 2001 From: Marcin Szczepanski Date: Fri, 22 Sep 2023 11:25:34 +1000 Subject: [PATCH] Fix bug with cache and glob entries This fixes #8477. I wasn't able to get a reliable repro in a test for this, but I have previously manually applied this patch in a large codebase where we saw this issue and it resolved it. --- packages/core/core/src/RequestTracker.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/core/core/src/RequestTracker.js b/packages/core/core/src/RequestTracker.js index 38885aa829a..124f9843d2e 100644 --- a/packages/core/core/src/RequestTracker.js +++ b/packages/core/core/src/RequestTracker.js @@ -764,15 +764,19 @@ export class RequestGraph extends ContentGraph< let fileNameNodeId = this.getNodeIdByContentKey( 'file_name:' + basename, ); + // Find potential file nodes to be invalidated if this file name pattern matches - let above = this.getNodeIdsConnectedTo( + let above: Array = []; + for (const nodeId of this.getNodeIdsConnectedTo( fileNameNodeId, requestGraphEdgeTypes.invalidated_by_create_above, - ).map(nodeId => { + )) { let node = nullthrows(this.getNode(nodeId)); - invariant(node.type === 'file'); - return node; - }); + // these might also be `glob` nodes which get handled below, we only care about files here. + if (node.type === 'file') { + above.push(node); + } + } if (above.length > 0) { didInvalidate = true;