partytown
partytown copied to clipboard
Cannot read properties of null (reading 'Error')
- [ ] I am interested in helping provide a fix!
Describe the bug We have received some errors:
(debug) e.top is null
Cannot read properties of null (reading 'Error')
This error was happing in this line in the file (~partytown/debug/partytown-sandbox-sw.js):
const serializedValueIsError = value => value instanceof window.top.Error;
Iframe and main application have the same domains and we didn't have errors with cross domain communication. Because of partytown is changing the main window history object, our application was broken and we couldn't navigation by page. Can you help, please, we don't understand how it is possible window.top = null
Expected behavior Application navigation must work, if iframe has error
Partytown version 0.6.2
Additional context
devices: Samsung SM-A525F (Chrome Mobile 103.0.0) Samsung Internet 17.0 (Samsung SM-J415FN) Huawei STF-L09 (Chrome Mobile 103.0.0)
I also ran into this error, and figured out that it happens after the partytown iframe is removed from the page.
With most frontend frameworks, the easiest way to prevent this is to mount the framework to a div inside the body tag, instead of the body tag itself.
I'm using Hotwire's Turbo library, which makes the workaround a little harder, but I was still able to do it by wrapping the main content with <turbo-frame id="main-frame" turbo-action="advance" data-turbo-progress-bar="true">
, putting a <turbo-stream>
tag inside that to update the title and meta tags after navigation, and using this snippet to show the progress bar that normally only appears for root-level navigation.
@IcyDefiance, do you have any recommendation for fixing this issue but with a project that uses turbo links?
Hey, what's up?
Anyone had this same issue with NextJS? This issue is appearing a lot in a NextJS 12 project that I develop and I already tested implementing Partytown via experimental integration of NextJS and following the manual implementation present in the Partytown's documentation.