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

Cache bundle graph on failure #9366

Merged
merged 4 commits into from
Nov 9, 2023

Conversation

irismoini
Copy link
Contributor

@irismoini irismoini commented Nov 7, 2023

↪️ Pull Request

This PR adds logic to write Parcel's bundle graph to the cache if an error occurs during bundling.

Currently Parcel’s requestGraph is written to the cache at the end of a build or when interrupted with ctrl-c. Parcel’s bundleGraph is stored in node.value.results in the requestGraph and is written to the cache as part of the requestGraph's write to cache. If an error occurs during bundling however, the bundleGraph is never stored in a requestGraph node and as a result isn't written to the cache. This PR adds code to also store the bundleGraph in a requestGraph node if an error occurs during bundling.

Ideally, we'd eventually like to be able to replicate failed builds from the Parcel cache and this PR is a step towards that.

💻 Examples

NA

🚨 Test instructions

NA

✔️ 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

@irismoini irismoini self-assigned this Nov 7, 2023

let bundleGraphPath = path.join(
resolvedOptions.cacheDir,
bundleGraphCacheKey + '-0',
Copy link
Contributor Author

@irismoini irismoini Nov 7, 2023

Choose a reason for hiding this comment

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

Not sure if this is the best way to determine the bundleGraphPath. Currently being determined here . Which means if that changes, this code will break, but I have no way of accessing this function directly, so this is currently hardcoded.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe getFilePath() should be added to the Cache interface? /cc @JakeLane

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I think that would be reasonable.

Though I think it would be more maintainable for the integration test if we used the cache interface to load the blob instead, as we're duplicating business logic here.

Copy link
Member

Choose a reason for hiding this comment

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

Is the goal of the this change to be able to access the graphs via parcel-query? You could use that in the test

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mischnic For now we're just looking to confirm that the bundleGraph is written to cache if an error occurs during bundling w/ the ultimate goal of being able to replicate errors from the parcel cache.
@JakeLane I made a change based on what I thought you meant, lmk if you meant something else!

@irismoini irismoini merged commit d58e336 into v2 Nov 9, 2023
15 of 16 checks passed
@alshdavid alshdavid mentioned this pull request Nov 13, 2023
@mischnic mischnic deleted the imoini/P2X-1115-cache-bundle-graph-on-failure branch December 2, 2023 08:17
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.

4 participants