kwhitley / itty-router

A little router.
MIT License
1.77k stars 78 forks source link

Invalid Regular Expression #124

Closed TheDojoSamurai closed 1 year ago

TheDojoSamurai commented 1 year ago

I am getting this error, but only when running my ReactJS app in a mobile browsers.

Any idea on how to solve this?

2022-11-01 at 11 59 AM

kwhitley commented 1 year ago

That's super weird... in particular, the error, because at that stage, no group names exist... it's actually building them (group names exist as the regex that's returned from that regex).

kwhitley commented 1 year ago

Btw, it probably won't fix your issue, but you can certainly try itty-router@next (the upcoming full TS rewrite) and see what you get...

TheDojoSamurai commented 1 year ago

@kwhitley Thanks for the quick response.

In my context itty-router is a dependent of https://github.com/graphprotocol/graph-client, so not sure how to force it to use itty-router@next (Crosspost here: https://github.com/graphprotocol/graph-client/issues/326)

Also oddly enough it only happens on mobile browsers, desktop all works as expected.

kwhitley commented 1 year ago

I’ll set up a couple experiments tomorrow with the main branch and next on mobile. Quick question… how are you even seeing errors on mobile in the first place?

TheDojoSamurai commented 1 year ago

Great.

Catching errors on mobile was new to me also, this helped: https://www.lifewire.com/activate-the-debug-console-in-safari-445798

Then used ngrok to access my site. local IP was blocked and didn't want to open up my firewall.

TheDojoSamurai commented 1 year ago

@kwhitley Any progress on this? thanks

Qalamar commented 1 year ago

Facing this issue as well.

I’ll set up a couple experiments tomorrow with the main branch and next on mobile. Quick question… how are you even seeing errors on mobile in the first place?

In our case this only happens on iOS Safari, Installing Playwright and running npx playwright wk http://localhost:3001 should allow you to see something like this: image

I temporarily fixed the issue by manually editing yarn.lock by pinning to an older version of itty-router (2.6.1)

"@graphql-mesh/http@0.2.6":
  version "0.2.12"
  resolved "https://registry.yarnpkg.com/@graphql-mesh/http/-/http-0.2.12.tgz#b029d8a39a3594f710526e9974da3fc281b54e98"
  integrity sha512-tR7semZ6S0SCJSualsjP/4AESdXPPaZM7ZnWoU39ls2vMePIKKZSv8YwG7nM667k5lnPpMAC0ohPnfunS/j4+g==
  dependencies:
    "@graphql-mesh/cross-helpers" "0.2.9"
    "@graphql-mesh/runtime" "0.44.31"
    "@graphql-mesh/types" "0.85.7"
    "@graphql-mesh/utils" "0.42.6"
    "@whatwg-node/fetch" "^0.5.0"
    "@whatwg-node/server" "^0.4.10"
    graphql-yoga "3.0.0-next.10"
    itty-router "2.6.1" // instead of 2.6.6
    itty-router-extras "0.4.2"
    tslib "^2.4.0"
kwhitley commented 1 year ago

I temporarily fixed the issue by manually editing yarn.lock by pinning to an older version of itty-router (2.6.1)

This is helpful, thanks!

kwhitley commented 1 year ago

Actually I have a question here... is there any way you can find the matching route path (most important) and request URL that was fed to this when it failed? Curious if the generated group name has anything to do with this...

Aside from unlikely build differences between 2.6.1 and the latest on main is this line:

v2.6.1 image

v2.6.6 image

To see how/why the generated group name (occurs after this step), it would really help to know what's being fed to it! :)

kwhitley commented 1 year ago

No one saw that...

kwhitley commented 1 year ago

To introspect, find out wherever the router is being implemented, and after the routes are registered, if you log the router.routes, you should see an array of routes, each with 3 items: the 2nd being the generated regex for the route (what I need)

kwhitley commented 1 year ago

Marking this as closed for now, because itty-router@next is releasing with some changes to the Regex that may fix this issue.

If it doesn't, please reopen and let's investigate further!