I understand web workers and write an application ( github ) for downloading the list of VKontakte group members. Authorization and receipt of the group id occurs in the “frontend”, and a long download is entrusted to the “worker” - the dedicated web worker 'y.
On groups up to 3.5 million works. But I tried MDK with their 7 million and ran into a console error: InternalError: too much recursion
. Firefox 41.0.1, os x 10.11.
How to more accurately understand the cause of this error?
Could this be a data memory limit (I assume that about 70 megs weigh the id in text form)? Or is it how I crookedly organized calls to api - is there a callback snowball winding up somewhere?
You can reproduce the error here : log in via VC and enter the mdk
group. I fall off at 65–71%.
I make requests to the VKontakte API via jsonp : I form the url of the request and add the callback
parameter with the name of the function that I call “on return”. And I execute importScripts()
with this url.
All code is wrapped in an object that hangs its method for handling a callback:
self.callback = this.runLoop.bind(this);
Maybe this design creates an extra round of call stack?
I would be grateful for the ideas on the debugger worker, as well as help in debugging the project.
importScripts
- you run it inrunLoop
, then without leaving it the same method is called again, etc. Did not try to contact VC asynchronously, through the same ajax? Then the start of the method would always be "clean", i.e. without any recruitment - BOPOHXMLHttpRequest
will not work cross-domain. Therefore, jsonp cimportScripts()
. It is asynchronous. - Sergiksconsole.log(1);
afterimportScripts
console.log(1);
and put a breakpoint on it. What do you think - when will it work for you? And what kind of asynchrony are you talking about? There is no asynchrony, there is synchronism, there is a limit of recursion, which you rest against - BOPOHsetTimeout(function() {importScripts (url);}, 100)
- reached 100%, i.e. just did what I suggested - the call to VC occurs asynchronously - BOPOH