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

Partytown tries to turn an image/gif response into a function #245

Closed
1 task done
ricardokojo opened this issue Aug 24, 2022 · 3 comments · Fixed by #247
Closed
1 task done

Partytown tries to turn an image/gif response into a function #245

ricardokojo opened this issue Aug 24, 2022 · 3 comments · Fixed by #247

Comments

@ricardokojo
Copy link

ricardokojo commented Aug 24, 2022

  • I am interested in helping provide a fix!

Describe the bug
I've stumbled upon this issue because we had the same problem.

Debugging it, we've discovered that the problem is that https://googleads.g.doubleclick.net/pagead/viewthroughconversion/${SOME_NUMBER_ID}/ returns (after some redirects) a GIF.

Partytown tries to wrap it in an anonymous function, which generates the error message.

To Reproduce
Steps to reproduce the behavior:

  1. Have a doubleclick as a Partytown script;
  2. Open your webpage;
  3. The error should be in the browser's console.

Reproduction link
I don't know how to reproduce it in a sandbox, as this script is added via GTM and I'm not lectured in Google platforms (Analytics, Ads, Tag Manager etc).

Expected behavior
Partytown should not try to run every response as Javascript, as it's possible to check the content-type response header

Partytown version
0.6.4

Screenshots
image

☝️ Error shown in the console.

image

☝️ Source code of the function that Partytown generated.

Additional context
Investigating the source files, we found that the error lies at receiveMessageFromSandboxToWorker arrow function from partytown-ww-sw.js.

Further down this block, it is possible to check the content-type of the response (rsp variable). However, I'm not exactly sure where to check it and which MIME-types to consider.

cc @leocwolter, who helped me debug
cc @orballo, who created the original issue (and might find this relevant)

@leocwolter
Copy link
Contributor

leocwolter commented Aug 25, 2022

Some other observations:

  • This probably occurs everytime a script added to partytown (in our case an Google Adsense script added through GTM) does a request which has a content-type different from text/javascript.
  • Since requesting a 1x1 GIF is a common old technique to send data to some other server, it should probably continue being requested;
  • The log appears to be printed by a console.error in a catch statement so it should NOT have any effect on the behaviour of other scripts. Besides that it is still a false positive that should not be printed to the console.

@mhevery
Copy link
Contributor

mhevery commented Aug 29, 2022

@leocwolter thank you for the PR fix!

@orballo
Copy link

orballo commented Aug 30, 2022

Oh, that's nice! I left the project where I was working with partytown so I couldn't find time to debug and figure out what was happening.

I'm glad you found a fix! Thanks @ricardokojo and @leocwolter! :D

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

Successfully merging a pull request may close this issue.

4 participants