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

[wrangler] debounce restarts when changes are made to the assets directory #6866

Merged

Conversation

zwily
Copy link
Contributor

@zwily zwily commented Sep 30, 2024

What this PR solves / how to test

When files change in the assets directory, wrangler was reloading the app for every file. When the assets are the result of a build (like with the remix compiler, for example), that results in a lot of unnecessary restarting. This debounces them similar to how Pages dev debounces.

Fixes #6865

Author has addressed the following

  • Tests
    • TODO (before merge)
    • Tests included
    • Tests not necessary because: A test would be nice, but I don't see any existing tests around the asset watching, and am not sure how to test when the code is reloaded. If you think it's necessary, let me know.
  • E2E Tests CI Job required? (Use "e2e" label or ask maintainer to run separately)
    • [] I don't know
    • Required
    • Not required because: can't run E2E for external PRs
  • Changeset (Changeset guidelines)
    • TODO (before merge)
    • Changeset included
    • Changeset not necessary because:
  • Public documentation
    • TODO (before merge)
    • Cloudflare docs PR(s):
    • Documentation not necessary because: I don't think this change requires docs, it seems too minor.

@zwily zwily requested a review from a team as a code owner September 30, 2024 23:45
Copy link

changeset-bot bot commented Sep 30, 2024

🦋 Changeset detected

Latest commit: 3053aca

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

This PR includes changesets to release 2 packages
Name Type
wrangler Patch
@cloudflare/vitest-pool-workers 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

@zwily
Copy link
Contributor Author

zwily commented Sep 30, 2024

I actually haven't been table to test this locally. This is my first time doing local wrangler dev, and I can't get my local copy to run... I keep getting this error about workerd:

Error:
You installed workerd on another platform than the one you're currently using.
This won't work because workerd is written with native code and needs to
install a platform-specific binary executable.

Specifically the "@cloudflare/workerd-darwin-arm64" package is present but this platform
needs the "@cloudflare/workerd-darwin-arm64" package instead. People often get into this
situation by installing workerd on macOS and copying "node_modules"
into a Docker image that runs Linux.

I will keep digging and trying to figure it out.

@zwily zwily force-pushed the debounce-restarts-on-assets-change branch from 656d40b to 3053aca Compare October 1, 2024 00:48
@zwily
Copy link
Contributor Author

zwily commented Oct 1, 2024

OK, I got this running locally and it does fix the problem. I also think we shouldn't show every file that changes, but that can be a separate PR.

Copy link
Contributor

github-actions bot commented Oct 1, 2024

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/11116530193/npm-package-wrangler-6866

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

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

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11116530193/npm-package-wrangler-6866 dev path/to/script.js
Additional artifacts:
npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11116530193/npm-package-create-cloudflare-6866 --no-auto-update
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11116530193/npm-package-cloudflare-kv-asset-handler-6866
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11116530193/npm-package-miniflare-6866
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11116530193/npm-package-cloudflare-pages-shared-6866
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11116530193/npm-package-cloudflare-vitest-pool-workers-6866
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11116530193/npm-package-cloudflare-workers-editor-shared-6866
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11116530193/npm-package-cloudflare-workers-shared-6866

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


wrangler@3.78.12 includes the following runtime dependencies:

Package Constraint Resolved
miniflare workspace:* 3.20240925.0
workerd 1.20240925.0 1.20240925.0
workerd --version 1.20240925.0 2024-09-25

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

@threepointone threepointone removed the e2e Run e2e tests on a PR label Oct 1, 2024
Copy link
Contributor

@RamIdeas RamIdeas left a comment

Choose a reason for hiding this comment

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

This needs to also be handled in the –x-dev-env flow

@penalosa penalosa mentioned this pull request Oct 1, 2024
12 tasks
@threepointone
Copy link
Contributor

@RamIdeas can you point me to where? I'll update the PR.

@threepointone
Copy link
Contributor

It looks like the multiple restarts don't even happen with --x-dev-env, so I don't think any changes are required there.

@RamIdeas
Copy link
Contributor

RamIdeas commented Oct 1, 2024

It looks like the multiple restarts don't even happen with --x-dev-env, so I don't think any changes are required there.

Ah ok cool I think the existing cancellation might already handle this by short-circuiting the reload when another begins

@andyjessop andyjessop merged commit c75b0d9 into cloudflare:main Oct 1, 2024
27 of 33 checks passed
@workers-devprod workers-devprod added the contribution [Holopin] Recognizes an open-source contribution, big or small label Oct 1, 2024
Copy link

holopin-bot bot commented Oct 1, 2024

Congratulations @zwily, the maintainer of this repository has issued you a holobyte! Here it is: https://holopin.io/holobyte/cm1qgpbst21620cleqcp3pamb

This badge can only be claimed by you, so make sure that your GitHub account is linked to your Holopin account. You can manage those preferences here: https://holopin.io/account.
Or if you're new to Holopin, you can simply sign up with GitHub, which will do the trick!

@workers-devprod workers-devprod mentioned this pull request Oct 1, 2024
@irvinebroque
Copy link
Contributor

Thank you!

@penalosa penalosa mentioned this pull request Oct 7, 2024
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution [Holopin] Recognizes an open-source contribution, big or small
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 BUG: Wrangler reloading local server for every updated/added/deleted file in [assets] path
7 participants