-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Fix an issue when invariant
is called by external libraries when no dev error message handler is loaded.
#12899
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
… dev error message handler is loaded.
🦋 Changeset detectedLatest commit: c11a112 The changes in this PR will be included in the next version bump. 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 |
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.
Pull Request Overview
This PR fixes an issue where invariant
function calls from external libraries would generate unhelpful error messages with encoded URLs when no dev error message handler is loaded. The fix ensures that when the message is already a string, it gets formatted directly instead of being wrapped in a URL.
- Adds string message handling to
getFallbackErrorMsg
function - Updates changeset documentation to describe the fix
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
File | Description |
---|---|
src/utilities/invariant/index.ts | Adds early return for string messages with proper argument substitution |
.changeset/rare-months-camp.md | Documents the bug fix in changeset |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
✅ Docs preview has no changesThe preview was not built because there were no changes. Build ID: d74bcfb67748ad6397670eba |
commit: |
size-limit report 📦
|
This fixes an error when
invariant
is called by external libraries and no dev error message handler is loaded.As in that case,
message
will be a string and not a compiled-away number, error messages for invariant violations would now look like this, including a link:For one, our error page couldn't display that (that part is already fixed), but also creating the link in the first place didn't make a lot of sense, since that string message could also just be printed out in the error message.
Verified with the pkg-pr-new build that no more urls are generated: