Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Adds error message for site with non-trailing asterisk #839

Merged
merged 2 commits into from
Nov 11, 2019

Conversation

EverlastingBugstopper
Copy link
Contributor

@EverlastingBugstopper EverlastingBugstopper commented Nov 4, 2019

Fixes #814

This PR adds an error message for users deploying a site to a route without a trailing asterisk.

$ wrangler publish
Error: The route in your wrangler.toml should have a trailing * to apply the Worker on every path.
route = test.averyharnish.com*

Open to suggestions on the error message itself, and if we think this should be a message::warn instead of a failure::bail. The reason I have it bailing here is because I see absolutely no scenario where you would deploy a site without a trailing asterisk. Even for single page applications I believe you still need the worker to run on every route.

@@ -37,6 +37,11 @@ pub fn publish(
validate_worker_name(&target.name)?;

if let Some(site_config) = target.site.clone() {
if let Some(route) = &target.route {
if !route.ends_with("*") {
failure::bail!("The route in your wrangler.toml should have a trailing * to apply the Worker on every path.\nroute = {}*", route)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd use message::warn and have this message clarify that without the trailing *, your site may not work as expected.

Copy link
Contributor

Choose a reason for hiding this comment

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

i agree, i don't think bailing is necessarily the right move.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah - if you see my original comment on the PR, I wasn't sure if we should bail or warn here. The reason I opted for bailing is because I'm 99% sure that it just breaks your site no matter what. If you do this the first time you're migrating your site from something else, your site will go down, even if you see the warning and fix it on the next push. I'm willing to change it to a warning, but I'm really not sure we want to go that "route" 😛

Copy link
Contributor

Choose a reason for hiding this comment

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

#iseewhatyoudidthere

my kneejerk reaction is always to say "listen, we don't necessarily know what a user plans on doing with this". However in this case, you make a pretty strong point that a worker that does not use a wild card route here will likely never serve anything other than the root index.html, which would be kind of useless.

either way though, i think gabbi's warning of "might not work as expected" is important.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

even if they were only serving index.html and nothing else (which is highly highly unlikely), it would still be in their best interest to have /* - if they have other workers that are more specific elsewhere, they will take precedence. I really really don't think we're going to have users come complaining that they can't deploy a worker without the asterisk aside from the usual complaint that its confusing why its necessary at all, which we aren't solving for currently.

Edit: I think that failing here would save way more people from deploying a broken site than just a warning would, and I really really do not anticipate people being upset about this even if they are only serving index.html. If that is their use case, it'll still work with a trailing asterisk no problem.

Copy link
Contributor

Choose a reason for hiding this comment

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

you've changed my mind. i do like the wording "might not work as expected".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ashleygwilliams I'd love to get your input on this

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Warn on route without trailing * for Workers Sites
4 participants