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: publish environment specific routes #517

Merged
merged 1 commit into from
Feb 23, 2022
Merged

fix: publish environment specific routes #517

merged 1 commit into from
Feb 23, 2022

Conversation

threepointone
Copy link
Contributor

This adds some tests for publishing routes, and fixes a couple of bugs with the flow.

  • fixes publishing environment specific routes, closes 🐛 BUG: Routes in wrangler.toml doesn't respect env #513
  • default workers_dev to false if there are any routes specified
  • catches a hanging promise when we were toggling off a workers.dev subdomain (which should have been caught by the no-floating-promises lint rule, so that's concerning)
  • this also fixes publishing environment specific crons, but I'll write tests for that when I'm doing that feature in depth

I expect to send some followup PRs for routes, but this should make it a little more stable right now

This adds some tests for publishing routes, and fixes a couple of bugs with the flow.
- fixes publishing environment specific routes, closes #513
- default workers_dev to false if there are any routes specified
- catches a hanging promise when we were toggling off a workers.dev subdomain (which should have been caught by the no-floating-promises lint rule, so that's concerning)
- this also fixes publishing environment specific crons, but I'll write tests for that when I'm doing that feature in depth

I expect to send some followup PRs for routes, but this should make it a little more stable right now
@changeset-bot
Copy link

changeset-bot bot commented Feb 22, 2022

🦋 Changeset detected

Latest commit: b0190d0

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

This PR includes changesets to release 1 package
Name Type
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

@@ -290,7 +293,7 @@ export default async function publish(props: Props): Promise<void> {
}
} else {
// Disable the workers.dev deployment
fetchResult(`${workerUrl}/subdomain`, {
await fetchResult(`${workerUrl}/subdomain`, {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this should have been caught by no-floating-promises 🤨

@github-actions
Copy link
Contributor

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

npm install --save-dev https://prerelease-registry.developers.workers.dev/runs/1882931742/npm-package-wrangler-517

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

npm install --save-dev https://prerelease-registry.developers.workers.dev/prs/517/npm-package-wrangler-517

Or you can use npx with this latest build directly:

npx https://prerelease-registry.developers.workers.dev/runs/1882931742/npm-package-wrangler-517 dev path/to/script.js

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.

Love it! Thanks for increasing the test coverage and the clean up.
Should we deprecate the route config? And just only ever use the routes field?

@@ -831,7 +831,7 @@ export async function main(argv: string[]): Promise<void> {
(args["compatibility-flags"] as string[]) ||
config.compatibility_flags
}
usageModel={config.usage_model}
usageModel={envRootObj.usage_model}
Copy link
Contributor

Choose a reason for hiding this comment

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

Beautiful!

Comment on lines +49 to +53
const triggers = props.triggers || envRootObj.triggers?.crons;
const routes =
props.routes ||
envRootObj.routes ||
(envRootObj.route ? [envRootObj.route] : undefined);
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason why this was moved above the account_id check?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the value of routes is needed for the default value of deployToWorkersDev

@threepointone
Copy link
Contributor Author

Should we deprecate the route config? And just only ever use the routes field?

I... don't know tbh. I haven't used it enough to have an opinion. 🤔

@threepointone threepointone merged commit 201a6bb into main Feb 23, 2022
@threepointone threepointone deleted the route-envs branch February 23, 2022 10:15
@github-actions github-actions bot mentioned this pull request Feb 23, 2022
mrbbot added a commit that referenced this pull request Oct 31, 2023
* Support `durableObjectsPersist` option

Uses cloudflare/workerd#302 to enable Durable Object persistence.

- `durableObjectsPersist: undefined | false | "memory:"` stores
  "in-memory"
- `durableObjectsPersist: true` stores under `.mf` on the file-system
- `durableObjectsPersist: "(file://)?<path>"` stores under `<path>`
  on the file-system

Note Miniflare 2 persisted in-memory data between options reloads. In
Miniflare 3, `workerd` restarts on every reload, so if we used
`workerd`'s in-memory storage, we'd lose data every time options
changed. To maintain Miniflare 2's behaviour, "in-memory" storage
isn't actually in-memory. Instead, we write to a temporary directory
and clean this up on `dispose()`/exit. 🙈

Also fixes a bug if multiple services bound to the same Durable
Object class. This would result in duplicate entries in
`durableObjectClassNames`. This has been changed from a `Map` of
`string[]`s to a `Map` of `Set<string>`s to enforce the uniqueness
constraint.

Closes #2403
Closes #2458

Internal ticket: DEVX-219

* fixup! Support `durableObjectsPersist` option

* fixup! Support `durableObjectsPersist` option

* fixup! Support `durableObjectsPersist` option
mrbbot added a commit that referenced this pull request Nov 1, 2023
* Support `durableObjectsPersist` option

Uses cloudflare/workerd#302 to enable Durable Object persistence.

- `durableObjectsPersist: undefined | false | "memory:"` stores
  "in-memory"
- `durableObjectsPersist: true` stores under `.mf` on the file-system
- `durableObjectsPersist: "(file://)?<path>"` stores under `<path>`
  on the file-system

Note Miniflare 2 persisted in-memory data between options reloads. In
Miniflare 3, `workerd` restarts on every reload, so if we used
`workerd`'s in-memory storage, we'd lose data every time options
changed. To maintain Miniflare 2's behaviour, "in-memory" storage
isn't actually in-memory. Instead, we write to a temporary directory
and clean this up on `dispose()`/exit. 🙈

Also fixes a bug if multiple services bound to the same Durable
Object class. This would result in duplicate entries in
`durableObjectClassNames`. This has been changed from a `Map` of
`string[]`s to a `Map` of `Set<string>`s to enforce the uniqueness
constraint.

Closes #2403
Closes #2458

Internal ticket: DEVX-219

* fixup! Support `durableObjectsPersist` option

* fixup! Support `durableObjectsPersist` option

* fixup! Support `durableObjectsPersist` option
mrbbot added a commit that referenced this pull request Nov 1, 2023
* Support `durableObjectsPersist` option

Uses cloudflare/workerd#302 to enable Durable Object persistence.

- `durableObjectsPersist: undefined | false | "memory:"` stores
  "in-memory"
- `durableObjectsPersist: true` stores under `.mf` on the file-system
- `durableObjectsPersist: "(file://)?<path>"` stores under `<path>`
  on the file-system

Note Miniflare 2 persisted in-memory data between options reloads. In
Miniflare 3, `workerd` restarts on every reload, so if we used
`workerd`'s in-memory storage, we'd lose data every time options
changed. To maintain Miniflare 2's behaviour, "in-memory" storage
isn't actually in-memory. Instead, we write to a temporary directory
and clean this up on `dispose()`/exit. 🙈

Also fixes a bug if multiple services bound to the same Durable
Object class. This would result in duplicate entries in
`durableObjectClassNames`. This has been changed from a `Map` of
`string[]`s to a `Map` of `Set<string>`s to enforce the uniqueness
constraint.

Closes #2403
Closes #2458

Internal ticket: DEVX-219

* fixup! Support `durableObjectsPersist` option

* fixup! Support `durableObjectsPersist` option

* fixup! Support `durableObjectsPersist` option
mrbbot added a commit that referenced this pull request Nov 1, 2023
* Support `durableObjectsPersist` option

Uses cloudflare/workerd#302 to enable Durable Object persistence.

- `durableObjectsPersist: undefined | false | "memory:"` stores
  "in-memory"
- `durableObjectsPersist: true` stores under `.mf` on the file-system
- `durableObjectsPersist: "(file://)?<path>"` stores under `<path>`
  on the file-system

Note Miniflare 2 persisted in-memory data between options reloads. In
Miniflare 3, `workerd` restarts on every reload, so if we used
`workerd`'s in-memory storage, we'd lose data every time options
changed. To maintain Miniflare 2's behaviour, "in-memory" storage
isn't actually in-memory. Instead, we write to a temporary directory
and clean this up on `dispose()`/exit. 🙈

Also fixes a bug if multiple services bound to the same Durable
Object class. This would result in duplicate entries in
`durableObjectClassNames`. This has been changed from a `Map` of
`string[]`s to a `Map` of `Set<string>`s to enforce the uniqueness
constraint.

Closes #2403
Closes #2458

Internal ticket: DEVX-219

* fixup! Support `durableObjectsPersist` option

* fixup! Support `durableObjectsPersist` option

* fixup! Support `durableObjectsPersist` option
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.

🐛 BUG: Routes in wrangler.toml doesn't respect env
2 participants