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

[miniflare] fix: cleanup temporary directory after shutting down workerd #4400

Merged
merged 1 commit into from
Nov 8, 2023

Conversation

mrbbot
Copy link
Contributor

@mrbbot mrbbot commented Nov 8, 2023

Fixes #4362.

What this PR solves / how to test:

Previously, Miniflare would register two exit hooks: one to remove its temporary directory, and one to shutdown workerd. These exit hooks are executed synchronously in the order they're registered: https://github.com/sindresorhus/exit-hook/blob/06b9fa48ef2c8245b42c558136d75e52ef833022/index.js#L14-L16. This meant we would try to remove the temporary directory before shutting down workerd. On Linux and macOS this is fine, but on Windows, this could lead to EBUSY errors as workerd still had an open handle on the directory. This change ensures we attempt to shutdown workerd before removing the directory. Since we can only clean up on a best effort basis when exiting, it also catches any errors thrown when removing the directory, in case the runtime doesn't shutdown fast enough.

Author has addressed the following:

  • Tests
    • Included
    • Not necessary because:
  • Changeset (Changeset guidelines)
    • Included
    • Not necessary because:
  • Associated docs
    • Issue(s)/PR(s):
    • Not necessary because: this is a bug fix for existing behaviour

Note for PR author:

We want to celebrate and highlight awesome PR review! If you think this PR received a particularly high-caliber review, please assign it the label highlight pr review so future reviewers can take inspiration and learn from it.

@mrbbot mrbbot requested a review from a team as a code owner November 8, 2023 11:49
Copy link

changeset-bot bot commented Nov 8, 2023

🦋 Changeset detected

Latest commit: 44a8340

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
miniflare Patch
@cloudflare/pages-shared Patch
wrangler Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

github-actions bot commented Nov 8, 2023

A wrangler prerelease is available for testing. You can install this latest build in your project with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/6797939581/npm-package-wrangler-4400

You can reference the automatically updated head of this PR with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/6797939581/npm-package-wrangler-4400

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/6797939581/npm-package-wrangler-4400 dev path/to/script.js
Additional artifacts:
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/6797939581/npm-package-miniflare-4400
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/6797939581/npm-package-cloudflare-pages-shared-4400

Note that these links will no longer work once the GitHub Actions artifact expires.


wrangler@3.15.0 includes the following runtime dependencies:

Package Constraint Resolved
miniflare workspace:* 3.20231025.1
workerd 1.20231030.0 1.20231030.0
workerd --version 1.20231030.0 2023-10-30

|

Please ensure constraints are pinned, and miniflare/workerd minor versions match.

Copy link

codecov bot commented Nov 8, 2023

Codecov Report

Merging #4400 (44a8340) into main (35be459) will increase coverage by 0.03%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4400      +/-   ##
==========================================
+ Coverage   75.28%   75.31%   +0.03%     
==========================================
  Files         223      223              
  Lines       12357    12357              
  Branches     3198     3198              
==========================================
+ Hits         9303     9307       +4     
+ Misses       3054     3050       -4     

see 3 files with indirect coverage changes

@mrbbot mrbbot merged commit 7678786 into main Nov 8, 2023
17 of 20 checks passed
@mrbbot mrbbot deleted the bcoll/miniflare-ebusy-fix branch November 8, 2023 14:51
@workers-devprod workers-devprod mentioned this pull request Nov 8, 2023
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.

[Miniflare] BUG: cleanup does not work in windows
2 participants