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

[discuss] JavaScript errors can halt update/refresh logic #474

Open
mwbrooks opened this issue Jan 5, 2017 · 3 comments
Open

[discuss] JavaScript errors can halt update/refresh logic #474

mwbrooks opened this issue Jan 5, 2017 · 3 comments

Comments

@mwbrooks
Copy link
Collaborator

mwbrooks commented Jan 5, 2017

Original issue

#291

Overview

When an error occurs while the page is loading, it can cause the update/refresh logic to fail to initialize or halt entirely.

Steps to Reproduce

Can someone please provide a small example that reproduces this error.

Discuss

Can we prevent this from occurring? If not, can we detect that the Mobile app is not refreshing from the client-side (CLI) or native-side (mobile app)?

@tylermakin
Copy link

From #291:

@mwbrooks I do not recall the specific bug that caused my script to stop but anything that prevents a page from loading properly should do the trick.

A simple bug that should cause this issue is calling an undefined variable:

console.log('This will appear on console');
var b = a;
console.log('This will not appear in console');

Adding this to your JavaScript should throw an error and stop any further JS from loading, which seems to be what is causing the PhoneGap Developer app from refreshing.

@surajpindoria
Copy link
Collaborator

Is this something that will get fixed once we add phonegap-plugin-developer-mode? @timkim

@timkim
Copy link
Contributor

timkim commented Jan 9, 2017

So far the best way to debug javascript errors is through:

  // err: error message
  // fileName: which file error occurs in
  // lineNumber: what line error occurs on
  window.onerror = function (err, fileName, lineNumber) {
    // alert or console.log a message
    alert(fileName, 'Line:', lineNumber, 'Error:', e.message);
  };

However, the user themselves have to put that in their app in order to see if an error fires or not. It might be worthwhile having that snippet within the developer mode plugin. Maybe have our own error reporter callback?

There are plans for using multi-webviews in the developer app, but that's a feature that will be coming sometime later this year. However, even using that doesn't quite solve broken js, but it will the user to easily go back to the main input screen.

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

No branches or pull requests

4 participants