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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃毃 Error: Uncaught ReferenceError: prompt is not defined #27904

Closed
ampprojectbot opened this issue Apr 21, 2020 · 2 comments
Closed

馃毃 Error: Uncaught ReferenceError: prompt is not defined #27904

ampprojectbot opened this issue Apr 21, 2020 · 2 comments
Labels
Stale Inactive for one year or more Type: Error Report An error reported by AMP Error Reporting

Comments

@ampprojectbot
Copy link
Member

Details

Error report: link
First seen: Apr 15, 2020
Frequency: ~ 48689/day

Stacktrace

Error: Uncaught ReferenceError: prompt is not defined
    at (uncaught-referenceerror-prompt-is-not-defined.js:1)
@ampprojectbot ampprojectbot added the Type: Error Report An error reported by AMP Error Reporting label Apr 21, 2020
@rcebulko
Copy link
Contributor

This appears to only be occurring on the domain https://hindi-news18-com.cdn.ampproject.org, (example page) so far, or at least that's the bulk of the reports. The publisher has code like the following:

function checkCookie()
        {
          var user = accessCookie("testCookie");
          if (user!="")
        	alert("Welcome Back " + user + "!!!");
          else
          {
            user = prompt("Please enter your name");
            num = prompt("How many days you want to store your name on your computer?");
            if (user!="" && user!=null)
            {
            createCookie("testCookie", user, num);
            }
          }
        }
		createCookie("JioPlayer","1",1);
		checkCookie();//# sourceURL=amp-script%5Bsrc=%22https://hindi.news18.com/amp-customjs.js?v=1%22%5D.js

This is within an amp-script[src=...] script. A few takeaways:

  1. According to the compatibility table, the Window.prompt API is not enabled in the worker DOM. Would it be feasible to stub blocked APIs in some way to alert publishers that they will fail?
  2. Errors occurring in an amp-script throw stacktraces outside of our code. Example:
Uncaught ReferenceError: prompt is not defined
    at checkCookie (amp-script[src="http鈥mjs.js?v=1"].js:28)
    at amp-script[src="http鈥mjs.js?v=1"].js:37

The amp-script stacktrace bit could be ignored on the error-reporting backend, but the runtime error handling should be able to handle these errors separately and report them as user errors.

/cc @ampproject/wg-runtime

@stale
Copy link

stale bot commented Oct 14, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Stale Inactive for one year or more label Oct 14, 2021
@stale stale bot closed this as completed Oct 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Stale Inactive for one year or more Type: Error Report An error reported by AMP Error Reporting
Projects
None yet
Development

No branches or pull requests

2 participants