-
Notifications
You must be signed in to change notification settings - Fork 438
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
[🐞] $instanceId$ not found
(e.g., 22fejj73w43 not found
) error when multiple tabs/pages are open
#492
Comments
Hey @techfg as we read this, we switched to atomics in a customer project and still see those kind of errors. It is somehow related to analytics.js. Also some of the |
Hi @hoebbelsB - Thanks for the insight. It's very possible that there are multiple issues going on, some in core partytown with very simple scenarios (similar to the tests I added in #493) and others related to more complex scenarios like GTM. For example, depending on your GTM configuration, there may be things like custom scripts, third-party scripts, etc. loaded that could lead to other issues/scenarios. For sure, the Regarding atomics, I'll admit that I didn't do extensive testing to see if I could trigger the This may be a situation where the low hanging fruit issues (from #493) get addressed, and then the next layer of issues are tackled. Couple of questions:
|
hey @techfg thanks for the fast reply. About the failing This is the result when partytown is enabled. First, the requests aren't of type This specific problem is visible all the time and sadly we are not able to change configurations on the gtm setup itself. We have to deal with what is there. But it all boils down to analytics, so no other 3rd party involved here. The instanceId error seems to only appear when multiple tabs are involved, though I couldn't even reproduce it once while testing this morning. Sorry for the squishy information, hope it's still helpful |
Hi @hoebbelsB - Based on what I've been seeing, once you encounter the As it pertains to GTM, since you aren't always able to reproduce the issue consistently, it could be something with a certain interaction/tag firing that is having issues. Without knowledge of your GTM, difficult to say for certain and although there may not be any third-party scripts, if you have any custom HTML that contains javascript, or utilize any GTM community templates, etc. there could be something in there. Also, if you have a Content Security Policy (CSP), the switch to atomics likely will require adjustments to that. If there is any way for you to copy your GTM container and then start stripping away pieces, you may be able to find something that way. The best advice I can give is to enable Partytown debugging and log all calls and then dig through the output to see if you can identify anything. From there and based on what you've shared thus far, while I can't be certain, I'm guessing your issue is different than the root cause of the issue I posted here in which case, would be best to create a new issue with an isolated repro. In meantime, hopefully this issue can get addressed as it will only help in your scenario whether or not its the same or different issue. |
hey @techfg thanks for the input. We've already activated logging for everything. Unfortunately it's not easy to debug as the error messages are not very insightful. Do you have any idea about the hanging network requests I've posted earlier? |
Hi @hoebbelsB - Yeah, debugging is a challenge :( Regarding the hanging network requests, my guess is that the first thing that goes wrong is the One last thought is if you have any internal links on your site that use |
For me it felt more like it's the other way around. First those requests fail, after some time also the instanceId errors appear. It's also entirely possible those two are not connected at all. |
Yeah, could be related to each other or separate but based on what you've described, why I think your issue(s) might be a different than the issue I posted here. What's the first error you see in the console? |
We are running into those hanging requests by guarantee on certain interactions. Mostly connected to soft navigations, routing in an SPA. It's an angular app. So the fetch errors are mostly the ones who are raised first |
Long shot but it seems you are using Google Universal Analytics (analytics.js) which was retired in July 2023 (unless you are on a commercial plan I think). That library hasn't been maintained I don't believe so possibly migrating to GA4 might be helpful. Again, total long shot, just thinking out loud. Either way, since everything works without PT, it should work with PT but there could be something in analytics.js that PT hasn't implemented a proxy for. |
you are right, this project is using the deprecated analytics.js. Some of the requests to the very same endpoint, from the very same script is failing. It doesn't look like missing support. Yeah, moving to ga4 is planned, but won't happen soon. Is it possible to exclude analytics from partytown somehow? |
adding analytics.js to the |
If this is blocking a go-live, would recommend that you just keep all of GTM on main thread. From there, would recommend you find a way to copy your GTM container and then strip back functionality until you can identify which piece of it is causing the issue. Once you have that, since you're able to reproduce this with a single tab which means its different than the problem identified in this issue, hopefully you can create an isolated repro and log a new issue in this repro with the details. |
EDIT: |
Describe the bug
When multiple tabs/pages are open within a browser (same window or separate), attempts to access the main thread encounter
$instanceId$ not found
errors (e.g.,22fejj73w43 not found
in prod build,Error finding instance "2dab62yogpr.d" on window 2
in debug build)Note
This only appears to occur when using service workers, when atomics are used, the problem does not seem to occur.
Reproduction
Repo: https://github.com/techfg/partytown/tree/add-multiple-pages-tests
PR: #493
Steps to reproduce
To reproduce the issue, either manual or automated testing can be performed. To prepare:
npm install
npm run build
Manual Testing
Any test that accesses the main thread after initial page load will reproduce the issue (e.g., Platform - Event, Error, History, Multiple Pages, Window, etc. / Integration - Event Forwarding, Facebook Pixel, Google Tag Manager, etc.).
To run the tests manually:
npm run serve
Event
test, click the 'inc'Expected Result: The test behaves as expected visually and no errors in the console of either tab/page
Actual Result; The test does not complete the expected outcome and error messages are visible in either one (or both) of the consoles of the open pages.
Automated Testing
Six (6) new tests have been added to automate the testing of multiple tabs/pages:
Note
For the gtm & facebook-pixel test, the problem does not reliably reproduce when following the open page, wait, open page, wait, act on page 1, act on page 2 sequence of steps. Running manually, these steps reproduce the issue every time. The automated test takes a slightly different sequence of steps which seems to reliably reproduce the issue.
To run the automated tests:
npm run test
Expected Result: All tests pass
Actual Result: 6 tests fail
Browser Info
Reproduced on Chrome, Firefox & Edge (didn't test others)
Additional Information
In the GTM test, the custom event
button-click
does not appear to fire a GA4 tag so no event is sent to GA. While this doesn't impact the tests directly, it may be helpful to update the GTM container to define a tag that fires on the custom eventbutton-click
to ensure a full cycle occurs when the button in the test is clicked.The text was updated successfully, but these errors were encountered: