-
Notifications
You must be signed in to change notification settings - Fork 953
Make assets
field optional in the Worker config when using assets
#8545
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
Conversation
🦋 Changeset detectedLatest commit: a43c246 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
34bc4b1
to
2200e9f
Compare
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/13958531711/npm-package-wrangler-8545 You can reference the automatically updated head of this PR with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/8545/npm-package-wrangler-8545 Or you can use npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13958531711/npm-package-wrangler-8545 dev path/to/script.js Additional artifacts:cloudflare-workers-bindings-extension: wget https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13958531711/npm-package-cloudflare-workers-bindings-extension-8545 -O ./cloudflare-workers-bindings-extension.0.0.0-v5b2018d36.vsix && code --install-extension ./cloudflare-workers-bindings-extension.0.0.0-v5b2018d36.vsix create-cloudflare: npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13958531711/npm-package-create-cloudflare-8545 --no-auto-update @cloudflare/kv-asset-handler: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13958531711/npm-package-cloudflare-kv-asset-handler-8545 miniflare: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13958531711/npm-package-miniflare-8545 @cloudflare/pages-shared: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13958531711/npm-package-cloudflare-pages-shared-8545 @cloudflare/unenv-preset: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13958531711/npm-package-cloudflare-unenv-preset-8545 @cloudflare/vite-plugin: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13958531711/npm-package-cloudflare-vite-plugin-8545 @cloudflare/vitest-pool-workers: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13958531711/npm-package-cloudflare-vitest-pool-workers-8545 @cloudflare/workers-editor-shared: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13958531711/npm-package-cloudflare-workers-editor-shared-8545 @cloudflare/workers-shared: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13958531711/npm-package-cloudflare-workers-shared-8545 @cloudflare/workflows-shared: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13958531711/npm-package-cloudflare-workflows-shared-8545 Note that these links will no longer work once the GitHub Actions artifact expires.
Please ensure constraints are pinned, and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, I just left a couple of small questions 🙂
if (!configPath) { | ||
throw new Error( | ||
`Config not found. Have you created a wrangler.json(c) or wrangler.toml file?` | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
like my other comment I am wondering about the reason to change this here, if we want to move away from assert
s shouldn't the other assert
calls in this file be converted as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally I believe that assertions should be checking that our assumptions about the state of the code is correct, e.g. that a value is indeed defined when we believe it should, or that a string is not empty, etc. A failing assert()
call raises an AssertionError
rather than an Error
, which we could capture and send to Sentry, for example.
A failing assertion should indicate a bug in our code. We don't want "expected" user errors from polluting that signal.
I would be surprised if this is contentious.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me, I was just wondering, thanks for the clarification 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should switch other assert
calls to also check + throw (e.g. https://github.com/cloudflare/workers-sdk/pull/8545/files/f38f7894727403adb95a081810bb968c0aaf1ea0#diff-07b674c7cc878770162aa8ec047d225e4341a1cc0ce4eca507d29217ebdbca62R139) mainly for consistency sake 🤔
f38f789
to
a43c246
Compare
Fixes #8301.
This makes the
assets
field optional when using assets. Assets are now included at build time if the client environment is being built.I've also replaced use of
assert
in cases of user error and ensured that Worker config warnings are only displayed once at build time.