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 assets + custom build = infinite loop #6881

Merged
merged 5 commits into from
Oct 3, 2024
Merged

Conversation

RamIdeas
Copy link
Contributor

@RamIdeas RamIdeas commented Oct 2, 2024

What this PR solves / how to test

Fixes #6876

Previously, if a build.custom command output files into the assets.directory, it caused the command to run again in an infinite loop.

This was caused by the assets watcher in the ConfigController to trigger a configUpdate event – with the intention of triggering a runtime reload – which caused the BundleController to trigger a full build.

The assets watcher has now been moved to the BundleController and triggers a bundleCompleted event instead – with the intention of triggering a runtime reload where Miniflare itself reads the new assets from the filesystem.

Author has addressed the following

  • Tests
    • TODO (before merge)
    • Tests included
    • Tests not necessary because:
  • E2E Tests CI Job required? (Use "e2e" label or ask maintainer to run separately)
    • I don't know
    • Required
    • Not required because:
  • 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: bug fix

Copy link

changeset-bot bot commented Oct 2, 2024

🦋 Changeset detected

Latest commit: 451510c

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

Copy link
Contributor

github-actions bot commented Oct 2, 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/11161082317/npm-package-wrangler-6881

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

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

Or you can use npx with this latest build directly:

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

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


wrangler@3.79.0 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.

@zwily
Copy link
Contributor

zwily commented Oct 2, 2024

I tried this out... I updated my test app to point to this PR build:

https://github.com/zwily/remix-wrangler-much-restarting

(Note that I did have to set assets.watch_dir - without that, wrangler never reloaded.)

Now when I run npm run dev and then edit a file, it does not result in infinite rebuilds. However, HMR appears to be broken. Whenever I change a file it rebuilds, and wrangler reloads, but the browser never updates until I force a refresh.

@RamIdeas
Copy link
Contributor Author

RamIdeas commented Oct 2, 2024

I tried this out... I updated my test app to point to this PR build:

https://github.com/zwily/remix-wrangler-much-restarting

(Note that I did have to set assets.watch_dir - without that, wrangler never reloaded.)

Now when I run npm run dev and then edit a file, it does not result in infinite rebuilds. However, HMR appears to be broken. Whenever I change a file it rebuilds, and wrangler reloads, but the browser never updates until I force a refresh.

I think you're looking for the --live-reload flag. We don't support HMR yet – instead we restart your worker upon changes, but this is different from live reload where we tell the browser something changed and trigger a page reload.

@RamIdeas RamIdeas marked this pull request as ready for review October 2, 2024 16:13
@RamIdeas RamIdeas requested a review from a team as a code owner October 2, 2024 16:13
Copy link
Contributor

@emily-shen emily-shen left a comment

Choose a reason for hiding this comment

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

thanks for fixing this!

packages/wrangler/e2e/dev.test.ts Outdated Show resolved Hide resolved
@RamIdeas
Copy link
Contributor Author

RamIdeas commented Oct 3, 2024

Can't get the Windows tests to begin and want this fix in today's release which will run them anyway

Going to skip the last job and merge anyway

@RamIdeas RamIdeas merged commit 7ca37bc into main Oct 3, 2024
21 of 22 checks passed
@RamIdeas RamIdeas deleted the assets-custom-build branch October 3, 2024 16:13
@workers-devprod workers-devprod mentioned this pull request Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
e2e Run e2e tests on a PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 BUG: Infinite building with --x-dev-env and an app with a build
5 participants