Node Giving Unhandledpromiserejection Warning, When I'm *sure* I'm Catching The Rejection
I'm using node-libcurl. I've got a little module in which I have a queue for curl requests. Here's what the function looks like to actually make the curl request: const Curl = requ
Solution 1:
You're probably catching the reject on the queue and not on the stack. You get that error (warning) with the following code:
var p = Promise.reject("hello world");//do not catch on the stacksetTimeout(
x=>p.catch(err=>console.log("catching:",err))//caught error on queue
,100
);
If you're going to catch the reject on the queue then you can do the following:
saveReject = p =>{
p.catch(ignore=>ignore);
return p;//catch p but return p without catch
}
var p = saveReject(Promise.reject("hello world"));//creating promise on the stacksetTimeout(
x=>p.catch(err=>console.log("catching:",err))//caught error on queue
,100
);
Information about queue and stack can be found here.
Post a Comment for "Node Giving Unhandledpromiserejection Warning, When I'm *sure* I'm Catching The Rejection"