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

chore: shrink error messages shipped to client #11551

Merged
merged 6 commits into from
Jan 9, 2024
Merged

Conversation

benmccann
Copy link
Member

No description provided.

Copy link

changeset-bot bot commented Jan 9, 2024

🦋 Changeset detected

Latest commit: d7fcbf2

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

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

@@ -65,7 +67,9 @@ export function parse_route_id(id) {
const match = param_pattern.exec(content);
if (!match) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could remove this whole block on the client side I think, the manifest generation would fail on this so it never gets here on the client.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like you removed it altogether,
I don't remember the specifics but iirc the error during manifest generation comes from the same place, so it can only be removed in the client bundle.

const { pattern, params } = parse_route_id(id);

@Rich-Harris
Copy link
Member

I think we should probably have a more principled approach to this problem — rather than making messages shorter (read: less helpful) in production, what if we did something similar to what React does and printed errors/warnings with codes that pointed to documentation? It could be as simple as this

@dummdidumm
Copy link
Member

We definitly should have such an approach to our error messaging in the mid term

// Skip invalid params.
// Params and matcher names can only have underscores and alphanumeric characters.
// We'll never hit this because mnifest generation would have failed.
if (!match) return;
Copy link
Member

Choose a reason for hiding this comment

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

if we never hit it, why do we have this line at all? surely a type assertion would be sufficient?

we should probably be separating these changes into different PRs — this isn't related to error messages (which i think we should solve properly rather than with piecemeal changes), and the disable_hash stuff is a behaviour change that probably warrants discussion

Copy link
Member Author

Choose a reason for hiding this comment

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

I like your idea about how to handle error messages. If we had that, I don't think we should change this though - better to ship no error message than a small unreachable one

@benmccann
Copy link
Member Author

benmccann commented Jan 9, 2024

I think we should probably have a more principled approach to this problem — rather than making messages shorter (read: less helpful) in production, what if we did something similar to what React does and printed errors/warnings with codes that pointed to documentation? It could be as simple as this

Yes, I like that idea. If we do that, I think I'd still want all the changes here:

  • we shouldn't ship an unreachable error
  • removing the word "was" makes the error messages read better
  • we're also removing code that we could avoid on the client and a smaller error message alone doesn't get us that

I could clarify the changeset message to say "remove and clarify error messages" or something along those lines. I'd be happy to break this into multiple PRs, but size-wise this is a nice size PR and we'd end up with three pretty small PRs if I did each of those changes separately. I do like the idea of having an errors page, but if we're wanting to split PRs, I don't think I'd mix it in with these changes and it would be better to do it separately.

@Rich-Harris Rich-Harris merged commit 8468af5 into main Jan 9, 2024
13 checks passed
@Rich-Harris Rich-Harris deleted the smaller-error-msgs branch January 9, 2024 15:27
@github-actions github-actions bot mentioned this pull request Jan 9, 2024
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.

4 participants