Skip to content
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

[Bug]: Upgrading from 6.4.3 to 6.4.4 breaks our application #10218

Closed
victorcarvalhosp opened this issue Mar 16, 2023 · 4 comments
Closed

[Bug]: Upgrading from 6.4.3 to 6.4.4 breaks our application #10218

victorcarvalhosp opened this issue Mar 16, 2023 · 4 comments
Labels

Comments

@victorcarvalhosp
Copy link

victorcarvalhosp commented Mar 16, 2023

What version of React Router are you using?

6.4.4

Steps to Reproduce

We have a Figma extension that runs inside an iframe and using version 6.4.3 or lower it works just fine. But as soon we update to 6.4.4 or higher it doesn't work anymore.

If we switch from <HashRouter> to <MemoryRouter> the error is not thrown, but the router simply doesn't work. We modified the Routes path accordingly to the documentation and it still doesn't work.

We didn't expect a minor version upgrade to break our application, and we haven't found a way around this error so far, so any help will be very much appreciated!

Expected Behavior

updating from 6.4.3 to 6.4.4 or higher version should work fine as it's not a breaking change

Actual Behavior

Everything works fine on version 6.4.3 - but as soon as we update to 6.4.4 or higher we start to see this error message:

VM538:34045 Uncaught TypeError: Failed to construct 'URL': Invalid URL
    at createURL (<anonymous>:34045:10)
    at Object.encodeLocation (<anonymous>:34139:17)
    at NavLinkWithRef (<anonymous>:147921:57)
    at renderWithHooks (<anonymous>:132022:18)
    at updateForwardRef (<anonymous>:134938:20)
    at beginWork (<anonymous>:137348:16)
    at HTMLUnknownElement.callCallback (<anonymous>:119881:14)
    at HTMLUnknownElement.sentryWrapped (<anonymous>:37690:17)
    at Object.invokeGuardedCallbackDev (<anonymous>:119930:16)
    at invokeGuardedCallback (<anonymous>:119994:31)
    at beginWork$1 (<anonymous>:143163:7)
    at performUnitOfWork (<anonymous>:142272:12)
    at workLoopSync (<anonymous>:142178:5)
    at renderRootSync (<anonymous>:142146:7)
    at performConcurrentWorkOnRoot (<anonymous>:141450:74)
    at workLoop (<anonymous>:156223:34)
    at flushWork (<anonymous>:156196:14)
    at MessagePort.performWorkUntilDeadline (<anonymous>:156490:21)
@victorcarvalhosp victorcarvalhosp changed the title [Bug]: Upgrading from 6.4.3 to 6.4.4 breaks the app [Bug]: Upgrading from 6.4.3 to 6.4.4 breaks our application Mar 16, 2023
@timdorr
Copy link
Member

timdorr commented Mar 18, 2023

This is most likely caused by #9682, though that is a valid fix. Instead, we probably need to check for window.parent or something like that.

@brophdawg11
Copy link
Contributor

Would you be able to provide more information on the specific URL that's throwing this error by either adding a debugger or a logpoint? Presumably the error is coming from this line so knowing what window looks like at that point would be useful: https://github.com/remix-run/react-router/blob/main/packages/router/history.ts#L676

@brophdawg11
Copy link
Contributor

brophdawg11 commented Apr 27, 2023

I'm going to close this out as stale, but please re-open with a reproduction if this is still an issue

@victorcarvalhosp
Copy link
Author

victorcarvalhosp commented Nov 27, 2023

@brophdawg11

Would you be able to provide more information on the specific URL that's throwing this error by either adding a debugger or a logpoint? Presumably the error is coming from this line so knowing what window looks like at that point would be useful: https://github.com/remix-run/react-router/blob/main/packages/router/history.ts#L676

Sorry for the long delay in replying here again. This is what I get if I log the document.URL or window.location.href:
data:text/html;base64,PHNjcmlwdD4KICAgICAgb25tZXNzYWdlID0gKGV2ZW50KSA9PiB7CiAgICAgICAgaWYgKGV2ZW50LnNvdXJjZSA9PT0gd2luZG93LnBhcmVudC5wYXJlbnQucGFyZW50ICYmIGV2ZW50Lm9yaWdpbiA9PT0gImh0dHBzOi8vd3d3LmZpZ21hLmNvbSIpIHsKICAgICAgICAgIGRvY3VtZW50LndyaXRlKCI8c2NyaXB0PiIgKyAiXG4gZG9jdW1lbnQuY2xvc2UoKTtcbiBkb2N1bWVudC5hZGRFdmVudExpc3RlbmVyKCdrZXlkb3duJywgKGUpID0+IHtcbiAgIGlmIChlLmtleUNvZGUgPT09IDgwIC8qIFAgKi8gJiYgIWUuc2hpZnRLZXkgJiYgZS5hbHRLZXkgJiYgI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vcmlnaW4gKyAnXCInLCAndG8gdGhlIG5ldHdvcmtBY2Nlc3MgPiBhbGxvd2VkRG9tYWlucyBmaWVsZCBpbiB5b3VyIG1hbmlmZXN0Lmpzb24uJylcbiAgICAgICAgICB9IGNhdGNoIHtcbiAgICAgICAgICAgIC8vIFRoaXMgaXMgdG8gbWFrZSBzdXJlIHdlIGRvbid0IGNyYXNoIGlmIHRoZSBibG9ja2VkVVJJIGlzIG5vdCBhIHZhbGlkIFVSTC5cbiAgICAgICAgICAgIC8vIFRoaXMgc2hvdWxkIG5ldmVyIGhhcHBlbiBzaW5jZSB3ZSdyZSBnZXR0aW5nIHRoZSB1cmwgZnJvbSB0aGUgV2ViIEFQSSwgYnV0IGJldHRlciBzYWZlIHRoYW4gc29ycnkuXG4gICAgICAgICAgfVxuICAgICAgICB9KSIgKyAiPC8iICsgInNjcmlwdD4iICsgZXZlbnQuZGF0YSkKICAgICAgICB9CiAgICAgIH0KCiAgPC9zY3JpcHQ+

I'm going to close this out as stale, but please re-open with a reproduction if this is still an issue

I'm sorry I can't create a reproduction as it just happens when running inside Figma(as it's a Figma extension)

EDIT: This time after switching from HashRouter to MemoryRouter our application is working fine. So we're moving ahead with MemoryRouter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants