Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug with cache and glob entries #9264

Merged
merged 2 commits into from
Oct 3, 2023
Merged

Conversation

marcins
Copy link
Contributor

@marcins marcins commented Sep 22, 2023

↪️ Pull Request

This fixes #8477. The code assumed that all the nodes would be file nodes and would fail the invariant if they weren't, however when using the glob resolver there could also be glob nodes. These can be safely ignored as globs are handled separately just below the affected code block.

The change refactors the code to filter out only the file nodes rather than failing on any unexpected node types.

🚨 Test instructions

I wasn't able to create a succesfully failing integration test, but have manually validated against the minimal reproduction in #8477.

✔️ PR Todo

  • Added/updated unit tests for this change
  • Filled out test instructions (In case there aren't any unit tests)
  • Included links to related issues/PRs

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.
// Find potential file nodes to be invalidated if this file name pattern matches
let above = this.getNodeIdsConnectedTo(
let above: Array<FileNode> = [];
for (const nodeId of this.getNodeIdsConnectedTo(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I originally had this code using .filter but Flow didn't like that, it didn't know that above only contained file nodes when passed in to invalidateFileNameNode on line 783.

@parcel-benchmark
Copy link

parcel-benchmark commented Sep 22, 2023

Benchmark Results

Kitchen Sink ✅

Timings

Description Time Difference
Cold 1.43s +12.00ms
Cached 288.00ms +43.00ms ⚠️

Cold Bundles

No bundle changes detected.

Cached Bundles

No bundle changes detected.

React HackerNews ✅

Timings

Description Time Difference
Cold 3.82s -55.00ms
Cached 406.00ms +1.00ms

Cold Bundles

Bundle Size Difference Time Difference
dist/logo.8dd07848.png 244.00b +0.00b 231.00ms +21.00ms ⚠️

Cached Bundles

No bundle changes detected.

AtlasKit Editor ✅

Timings

Description Time Difference
Cold 31.27s -67.00ms
Cached 2.11s +24.00ms

Cold Bundles

Bundle Size Difference Time Difference
dist/editorView.a0126b37.js 619.22kb +0.00b 11.47s -603.00ms 🚀
dist/refractor.3e0cc31b.js 598.96kb +0.00b 9.81s -859.00ms 🚀
dist/media-viewer.38e3999a.js 536.13kb +0.00b 9.81s -585.00ms 🚀
dist/popup.a77286c1.js 321.45kb +0.00b 9.81s -857.00ms 🚀
dist/ConfigPanelFieldsLoader.182d39bc.js 303.43kb +0.00b 6.71s -512.00ms 🚀
dist/EmojiPickerComponent.4a196252.js 188.61kb +0.00b 9.78s -615.00ms 🚀
dist/card.d06de810.js 138.91kb +0.00b 6.70s -521.00ms 🚀
dist/ConfigPanelFieldsLoader.28b428a5.js 82.73kb +0.00b 9.78s -615.00ms 🚀
dist/esm.34897092.js 62.95kb +0.00b 9.81s -857.00ms 🚀
dist/ElementBrowser.e8f01080.js 61.94kb +0.00b 6.71s -520.00ms 🚀
dist/archive.c374f622.js 59.90kb +0.00b 9.81s -858.00ms 🚀
dist/esm.bfca2115.js 59.30kb +0.00b 6.70s -521.00ms 🚀
dist/component-lazy.51d1dec9.js 58.94kb +0.00b 4.93s -259.00ms 🚀
dist/DatePicker.042aeb21.js 47.46kb +0.00b 4.93s -258.00ms 🚀
dist/esm.5e913efb.js 39.11kb +0.00b 9.81s -857.00ms 🚀
dist/DatePicker.dd4c3679.js 24.96kb +0.00b 4.93s -258.00ms 🚀
dist/smartMediaEditor.efa59853.js 21.68kb +0.00b 9.81s -858.00ms 🚀
dist/esm.aee9cbf1.js 20.43kb +0.00b 9.81s -857.00ms 🚀
dist/ConfigPanelFieldsLoader.2b7c03be.js 15.74kb +0.00b 6.71s -519.00ms 🚀
dist/ui.8c117104.js 14.48kb +0.00b 6.71s -520.00ms 🚀
dist/ConfigPanelFieldsLoader.5dfde67d.js 13.63kb +0.00b 6.71s -519.00ms 🚀
dist/dropzone.77a8e729.js 13.40kb +0.00b 9.81s -856.00ms 🚀
dist/pdfRenderer.01deafa1.js 12.04kb +0.00b 6.70s -521.00ms 🚀
dist/dropzone.1c15cdc1.js 11.48kb +0.00b 9.81s -856.00ms 🚀
dist/Toolbar.4d256e97.js 9.36kb +0.00b 9.81s -858.00ms 🚀
dist/clipboard.400013a2.js 7.92kb +0.00b 9.81s -857.00ms 🚀
dist/mobile-upload.3baad8e4.js 7.79kb +0.00b 6.71s -512.00ms 🚀
dist/mobile-upload.7a892a37.js 7.79kb +0.00b 6.71s -512.00ms 🚀
dist/mobile-upload.2102debb.js 7.79kb +0.00b 9.81s -857.00ms 🚀
dist/index.runtime.e32c1d2d.js 7.29kb +0.00b 9.83s -1.01s 🚀
dist/browser.0009c8b4.js 7.19kb +0.00b 9.81s -856.00ms 🚀
dist/index.b16227d6.css 4.08kb +0.00b 9.84s -1.03s 🚀
dist/media-viewer-analytics-error-boundary.60bdaa4c.js 3.18kb +0.00b 9.81s -858.00ms 🚀
dist/media-picker-analytics-error-boundary.c493f011.js 3.18kb +0.00b 9.81s -856.00ms 🚀
dist/media-card-analytics-error-boundary.74e0c7f9.js 3.18kb +0.00b 9.81s -858.00ms 🚀
dist/ru.0cf3f40e.js 2.81kb +0.00b 6.70s -520.00ms 🚀
dist/uk.282f23b1.js 2.76kb +0.00b 6.71s -519.00ms 🚀
dist/codeViewerRenderer.51140ec8.js 2.61kb +0.00b 9.81s -858.00ms 🚀
dist/th.137e1013.js 2.60kb +0.00b 6.70s -520.00ms 🚀
dist/ResourcedEmojiComponent.9a253c26.js 2.47kb +0.00b 4.93s -259.00ms 🚀
dist/pl.bce591be.js 2.25kb +0.00b 4.93s -257.00ms 🚀
dist/cs.bf42283b.js 2.23kb +0.00b 4.93s -258.00ms 🚀
dist/de.90d5c4fa.js 2.17kb +0.00b 4.93s -258.00ms 🚀
dist/fr.ff5d335f.js 2.13kb +0.00b 4.93s -259.00ms 🚀
dist/es.80bf0476.js 2.12kb +0.00b 4.93s -259.00ms 🚀
dist/hu.223c2cde.js 2.10kb +0.00b 4.93s -259.00ms 🚀
dist/fi.98bb8fa8.js 2.09kb +0.00b 4.93s -259.00ms 🚀
dist/ja.7d4156df.js 2.09kb +0.00b 4.93s -258.00ms 🚀
dist/vi.b46097db.js 2.09kb +0.00b 6.71s -519.00ms 🚀
dist/pt_BR.b9e37d37.js 2.06kb +0.00b 4.93s -258.00ms 🚀
dist/tr.c85d90a9.js 2.03kb +0.00b 6.71s -519.00ms 🚀
dist/ko.9c6bf469.js 1.98kb +0.00b 4.93s -258.00ms 🚀
dist/sv.1c06c95c.js 1.98kb +0.00b 6.70s -520.00ms 🚀
dist/it.04edb54a.js 1.97kb +0.00b 4.93s -259.00ms 🚀
dist/nb.9bd6db78.js 1.96kb +0.00b 4.93s -257.00ms 🚀
dist/da.d2d8303e.js 1.95kb +0.00b 4.93s -258.00ms 🚀
dist/nl.c4d12122.js 1.94kb +0.00b 4.93s -257.00ms 🚀
dist/zh_TW.b7c55aa6.js 1.86kb +0.00b 6.71s -519.00ms 🚀
dist/zh.b01fe721.js 1.84kb +0.00b 6.71s -519.00ms 🚀
dist/feedback.4b745631.js 1.76kb +0.00b 4.93s -259.00ms 🚀
dist/workerHasher.540c9790.js 1.56kb +0.00b 6.71s -513.00ms 🚀
dist/workerHasher.c840c607.js 1.56kb +0.00b 6.71s -514.00ms 🚀
dist/workerHasher.730f3766.js 1.56kb +0.00b 9.81s -856.00ms 🚀
dist/workerHasher.9b1fcdbf.js 1.56kb +0.00b 9.81s -857.00ms 🚀
dist/workerHasher.02b63a21.js 1.56kb +0.00b 9.81s -857.00ms 🚀
dist/heading6.e6e03f52.js 1.36kb +0.00b 4.93s -259.00ms 🚀
dist/heading5.d2f94d9d.js 1.23kb +0.00b 4.93s -259.00ms 🚀
dist/expand.c983e90a.js 1.18kb +0.00b 4.93s -259.00ms 🚀
dist/sk.4be9c93f.js 656.00b +0.00b 6.70s -520.00ms 🚀
dist/pt_PT.e211e609.js 635.00b +0.00b 4.93s -261.00ms 🚀
dist/et.88ef7cb4.js 633.00b +0.00b 4.93s -259.00ms 🚀
dist/simpleHasher.c14e20b4.js 589.00b +0.00b 6.71s -512.00ms 🚀
dist/simpleHasher.23db7a52.js 589.00b +0.00b 6.71s -514.00ms 🚀
dist/simpleHasher.eefc98b4.js 589.00b +0.00b 9.81s -856.00ms 🚀
dist/simpleHasher.47b9c809.js 589.00b +0.00b 9.81s -857.00ms 🚀
dist/simpleHasher.cadc19c6.js 589.00b +0.00b 9.81s -857.00ms 🚀
dist/is.5f045a22.js 495.00b +0.00b 4.93s -259.00ms 🚀
dist/ro.8d5b380a.js 482.00b +0.00b 6.70s -520.00ms 🚀
dist/en_GB.4c40e6c6.js 472.00b +0.00b 4.93s -259.00ms 🚀
dist/en.e1d21f6d.js 469.00b +0.00b 4.93s -258.00ms 🚀
dist/index.html 248.00b +0.00b 9.88s -1.01s 🚀

Cached Bundles

Bundle Size Difference Time Difference
dist/media-viewer.38e3999a.js 536.13kb +0.00b 9.96s +2.86s ⚠️
dist/ConfigPanelFieldsLoader.28b428a5.js 82.73kb +0.00b 9.97s +1.12s ⚠️
dist/pdfRenderer.01deafa1.js 12.04kb +0.00b 8.74s +1.65s ⚠️
dist/codeViewerRenderer.51140ec8.js 2.61kb +0.00b 8.74s -1.20s 🚀
dist/ro.8d5b380a.js 482.00b +0.00b 5.01s -2.09s 🚀

Three.js ✅

Timings

Description Time Difference
Cold 2.83s -3.00ms
Cached 310.00ms +3.00ms

Cold Bundles

No bundle changes detected.

Cached Bundles

No bundle changes detected.

Click here to view a detailed benchmark overview.

@mischnic
Copy link
Member

My reproduction still fails with 2.8.3 but then works fine starting from 2.9.0. 🤷 Must have been in this range

@devongovett devongovett merged commit f744d1b into v2 Oct 3, 2023
14 of 16 checks passed
@devongovett devongovett deleted the mszczepanski/fix-glob-cache-bug branch October 3, 2023 02:53
@marcins
Copy link
Contributor Author

marcins commented Oct 6, 2023

My reproduction still fails with 2.8.3 but then works fine starting from 2.9.0. 🤷 Must have been in this range

I did some bisecting out of curiousity and it seems the new resolver implementation fixed your repro. Bisect narrowed down the fix to 307268c.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AssertionError: (0, _assert().default)(node.type === 'file')
5 participants