-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix: prevent crash in buildLocation when params stringification fails (#6310) #6349
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1701,7 +1701,11 @@ export class RouterCore< | |||||||||||||||||||||||||||||||
| const fn = | ||||||||||||||||||||||||||||||||
| route.options.params?.stringify ?? route.options.stringifyParams | ||||||||||||||||||||||||||||||||
| if (fn) { | ||||||||||||||||||||||||||||||||
| Object.assign(nextParams, fn(nextParams)) | ||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||
| Object.assign(nextParams, fn(nextParams)) | ||||||||||||||||||||||||||||||||
| } catch (err) { | ||||||||||||||||||||||||||||||||
| // | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
Comment on lines
+1704
to
+1708
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add logging for stringify failures to aid debugging. While preventing crashes is the right approach for resilience, the empty catch block makes it difficult to diagnose when and why parameter stringification fails. This could hide bugs or configuration issues that developers need to be aware of. Consider logging the error at least in development mode: 🔍 Proposed enhancement to add development logging try {
Object.assign(nextParams, fn(nextParams))
} catch (err) {
- //
+ if (process.env.NODE_ENV !== 'production') {
+ console.warn(
+ `Failed to stringify params for route ${route.id}:`,
+ err,
+ )
+ }
}This maintains the crash prevention while providing visibility into stringify failures during development. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
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.
im not sure if just ignoring the exception is a good fix
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.
Should I add a console.warn inside a process.env.NODE_ENV !== 'production' check as CodeRabbit suggested?