I'm having a really weird bug in my HTML5 script. I wrote a sharepoint app completely in OData which uses a few HTML 5 webworker to do the number crunching in the background. This works perfect on all major browsers (FF, IE10+ Chrome, ...). However, when I perform a refresh or browse to the page again. The script still works as intended on FF and Chrome, but hangs on IE.
In my network view I see a request for the Worker.js file, but with a 304 NOT MODIFIED response. IE then just hangs there on that request with a status of (Pending). This issue only gets resolved when I clear my browser cache.
I correctly close all my threads with self.close().
Any idea what the issue could be? I'm not sure if it's a code issue, a browser issue or a server side issue but I can replicate the bug on Sharepoint online as well as on a local server. The whole project is JS only, so I can't modify headers as a workaround either.
UPDATE: I ran exactly the same code outside of a sharepoint environment, and it worked perfectly. Issue is Sharepoint related.
Stopping Web Workers terminate(); A terminated Web Worker will no longer respond to messages or perform any additional computations. You cannot restart a worker; instead, you can create a new worker using the same URL.
The script must be served from the same host or domain for security reasons, and that is also the reason that web workers won't work if we open the file locally with a file:// scheme.
You can create a single JavaScript file that is aware of its execution context and can act as both a parent script and a worker. Let's start off with a basic structure for a file like this: (function(global) { var is_worker = ! this.
You can run whatever code you like inside the worker thread, with some exceptions. For example, you can't directly manipulate the DOM from inside a worker, or use some default methods and properties of the window object.
using a time based querystring parameter prevents caching showing http status 200 on each refresh. tested on latest chrome, ie, ff;
var opus = new Worker("worker.js?q=" + new Date().getTime().toString() );
to be honest this a long shot as i do not have sharepoint right now
SharePoint sends the header:
Content-Disposition: attachment; filename="xyz.js"
X-Download-Options: noopen
and the IE Web Worker Implantation then does not run this web worker. (Tested in IE11) In the IE Network Monitor the request still on pending, even the Response text is visible.
I know so fare two workarounds:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With