Closed ifavo closed 2 years ago
Hi there!
I have a promise that has a timeout configured but sometimes there still will be a late response.
When this late response comes in, it throws an error which I can not catch.
throw new Error("This deferred has already been resolved");
How should I handle this situation?
This is how I setup the timeout:
var p = rpc.call("run", request.payload); p.timeout(1000); p.then( // success function(data){ callback(data); }, // error function(data){ sendError(data, callback); } );
And this is the other side:
rpc.expose("run", function(request){ var p = new Promise(); try { setTimeout(function () { p.callback(request); }, 5000); } catch (e) { p.errback(e); } return p; });
Thanks, Mario
Hi there!
I have a promise that has a timeout configured but sometimes there still will be a late response.
When this late response comes in, it throws an error which I can not catch.
How should I handle this situation?
This is how I setup the timeout:
And this is the other side:
Thanks, Mario