-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix(nextjs): parses the nextjs router correctly #12321
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
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.
Thank you for the PR!
Can I get a review for this PR? |
the stacktrace parsing seems reasonable to me, but I'd like to get @lforst opinion as our resident Next.js expert. |
Thanks for the PR, however, I think this is a bit of a bandaid solution and we should instead fix the parsing logic in the chromium stack trace parser. Started working on fixing the regex instead: #12373 |
If u want to update the chromium stack trace parser means that if Nextjs update their routes rules, u should to update this complexity regex. I think this isn't a good solution, because not all frameworks will have logic similar to Nextjs. Why should we increase this complexity to the global level and use it to handle all situations? Splitting it is the right way to reduce complexity. Otherwise, these parses should be refactored asap. |
If u want to handle more in the top-level parser. U also need to pay attention about the expo-router. I believe there are some similar framework custom routes, and it may be a better solution to spread them into different packages for processing. hope you can consider |
The reason this bug exists is because our chromium stack trace parser has a bug for frames that are in the global module scope and contain parentheses. See this (currently) failing test case. It absolutely makes sense to fix this in the core module. I fully agree with you that the regex is too complex and we should replace it with a state machine parser. That thing is 4+ years old. |
Ah understand, thx for your explanation. |
Is this PR still needed? |
No I think we fixed it in #12373. Thank you for the effort though! Much appreciated! |
Before submitting a pull request, please take a look at our
Contributing guidelines and verify:
yarn lint
) & (yarn test
).Fixes #12256
Background
Description
In case to increase the complexity of the original regex. I've added a new parser to handle the specific scenario of Next.js routes.
The core concept is to replace the key characters of Nextj.js routes as encoded characters. For example:
Why did I choose this way?
Because the original parser always split this stack line to
But the correct results should be
And I found the original parser is too complex to extend. So I create a new parser to handle this scenario and made it more proprietary and explicitly used for nextjs routing.
Did I test it?
Yes, I've tested it with the following cases: