Skip to content

fix: don't define error.message if it's not configurable #16149

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

Merged
merged 3 commits into from
Jun 14, 2025

Conversation

paoloricciuti
Copy link
Member

@paoloricciuti paoloricciuti commented Jun 13, 2025

Closes #16146

For the moment I changed this to not include the rest of the logs at all but i wonder if we should at least console.error them even if we don't change the original message (or if it could make sense to throw a different error, but that could be tricky).

Ok I've also added a console.error with the updated info, with an initial line that tells the user that it's not a second error, just a second console.error

WDYT?

Before submitting the PR, please make sure you do the following

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • Prefix your PR title with feat:, fix:, chore:, or docs:.
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.
  • If this PR changes code within packages/svelte/src, add a changeset (npx changeset).

Tests and linting

  • Run the tests with pnpm test and lint the project with pnpm lint

Copy link

changeset-bot bot commented Jun 13, 2025

🦋 Changeset detected

Latest commit: 53afa99

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

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

Playground

pnpm add https://pkg.pr.new/svelte@16149

Comment on lines 86 to 90
console.error(
"The following it's not a separate error: we usually modify the error message to show you this information but `message` was non configurable so we print them in a separate log.\n" +
error.message +
`\n${component_stack}\n`
);
Copy link
Member

Choose a reason for hiding this comment

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

This is ... a lot 😄 I would trim this down to just this, or just not log anything at all. I don't know how many people will have worse stacks as a result, but I doubt it's many

Suggested change
console.error(
"The following it's not a separate error: we usually modify the error message to show you this information but `message` was non configurable so we print them in a separate log.\n" +
error.message +
`\n${component_stack}\n`
);
console.error(
"[adjusted stack] " +
error.message +
`\n${component_stack}\n`
);

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I feared it would've been a lot but also wanted to make it clear it was not a separate error

@Rich-Harris
Copy link
Member

this seems like a real edge case. i would just skip the console.error personally

@paoloricciuti
Copy link
Member Author

this seems like a real edge case. i would just skip the console.error personally

Yeah it's also fine...let me revert it

@Rich-Harris Rich-Harris merged commit 113a3da into main Jun 14, 2025
14 checks passed
@Rich-Harris Rich-Harris deleted the non-configurable-errors branch June 14, 2025 15:14
This was referenced Jun 14, 2025
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.

App crashes trying to redefine message getter on the thrown Error if the error already contains the message as getter
3 participants