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

<!> Requests cancelled on iOS every 15 seconds when NoSleep.js is enabled (status code 0) #15

Closed
christianrondeau opened this issue Feb 12, 2016 · 0 comments

Comments

@christianrondeau
Copy link

The current implementation of NoSleep.js on iOS makes a redirect request and immediately cancels it, which resets the sleep timeout and therefore prevents the device from sleeping.

However, the window.stop() call actually cancels all pending requests, with a 0 status code. That means your application will "randomly" fail requests, like the connection was lost, but without any log of any kind.

This has been excruciatingly painful to debug (we were a whole team of people trying to diagnose networking issues and XmlHttpRequest constructs for two days), and obviously won't happen while you develop (unless it happens that your request was "in progress" when the stop call was made).

I think this library, even though very useful by itself, can cause serious damage if used unknowingly by misinformed developers.

I suggest these changes:

  • Every time NoSleep.js is enabled using enable(), display a console.warn (fallback to console.log) saying that requests may be cancelled while nosleep is enabled. This will allow developers to see what caused any failed requests following that message.
  • Clearly document on the home page that on iOS, requests will be cancelled every 15 seconds, and that any code running during a no sleep session should not make any HTTP requests (e.g. html presentations and kiosk apps are okay, and nosleep can be disabled when doing new xhr requests)
  • Clearly document on the home page that NoSleep.js cannot be used to keep a device awake while uploading large files.

Sadly, many production applications do not have active logging, and it's very easy to blame the wifi on an iPad (that's what we initially thought), therefore I would not underestimate the gravity of this issue.

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

No branches or pull requests

1 participant