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: try to serve assets from unencoded and encoded paths #6728

Merged
merged 7 commits into from
Sep 23, 2024

Conversation

emily-shen
Copy link
Contributor

@emily-shen emily-shen commented Sep 16, 2024

What this PR solves / how to test

Fixes WC-2693

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: no relevant e2es yet :(
  • 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: unreleased feat

@emily-shen emily-shen requested a review from a team as a code owner September 16, 2024 19:53
Copy link

changeset-bot bot commented Sep 16, 2024

🦋 Changeset detected

Latest commit: ec08675

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

This PR includes changesets to release 5 packages
Name Type
@cloudflare/workers-shared Patch
miniflare Patch
wrangler Patch
@cloudflare/pages-shared 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 Sep 16, 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/10961105486/npm-package-wrangler-6728

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

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

Or you can use npx with this latest build directly:

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

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


[email protected] includes the following runtime dependencies:

Package Constraint Resolved
miniflare workspace:* 3.20240909.4
workerd 1.20240909.0 1.20240909.0
workerd --version 1.20240909.0 2024-09-09

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

@emily-shen emily-shen marked this pull request as draft September 16, 2024 20:07
@emily-shen emily-shen force-pushed the emily/redirect-to-encoded branch 3 times, most recently from b31019a to 6416648 Compare September 19, 2024 20:32
@emily-shen emily-shen marked this pull request as ready for review September 19, 2024 20:34
Copy link
Contributor

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

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

Do we need to be careful to release these changes to Wrangler and workers-shared/asset-worker at the same time since we are changing the contract between them for these corner cases?

packages/workers-shared/asset-worker/src/handler.ts Outdated Show resolved Hide resolved
packages/workers-shared/utils/helpers.ts Outdated Show resolved Hide resolved
packages/workers-shared/utils/helpers.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@CarmenPopoviciu CarmenPopoviciu left a comment

Choose a reason for hiding this comment

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

pending on Pete's comments and changeset

Copy link
Member

@GregBrimble GregBrimble left a comment

Choose a reason for hiding this comment

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

Just that one question about normalizeFilePath!

),
hashPath(normalizeFilePath(relativeFilepath)),
// used absolute filepath here so that changes to the enclosing asset folder will be registered
hashPath(filepath + filestat.mtimeMs.toString()),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note what goes into contentHash doesn't actually matter, as long as it is uniquely associated with that filepath and updates with file changes. Just removed the filepath encoding because it was unnecessary and because normalizeFilePath() expects a relative filepath now.

@emily-shen emily-shen added e2e Run e2e tests on a PR and removed e2e Run e2e tests on a PR labels Sep 20, 2024
@edmundhung edmundhung merged commit 1ca313f into main Sep 23, 2024
33 of 34 checks passed
@edmundhung edmundhung deleted the emily/redirect-to-encoded branch September 23, 2024 10:32
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.

5 participants