You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// fragment of react-based appAxios.get('/api/robots/').then((res)=>{// could be .done() if... see belowletself=this;//setTimeout(function() { // -- this is ugly disabled workaround --self.setState(res.data);// if error happen here//}, 1);console.log(">>> RobotStore.state:",this.state);}).catch((res)=>{if(resinstanceofError){// it is catched here// unpredictable error, release throwError("test");// this DOES NOT work, error is swallowed (reject promise which is never used)}else{// HTTP error, handlethis.setState(this.getInitialState());}});
So axios (actually ES6 Promise engine) swallows app errors (which I want to bubble up and crash everything, as it's not runtime error).
I'ml aware of all aspects of this subject. What can you propose to solve this issue?
Monkeypatch .done? Leave setTimeout "trick" as it is? Or there are other ways?
The text was updated successfully, but these errors were encountered:
I am really frustrated with ES6 Promises. I was unfortunately unaware of the error swallowing behavior when I first started with axios, and thought that building on standardized, native Promises was the right thing. I am questioning that decision now.
I have thought a lot about what should be done, and have ultimately concluded that axios itself won't do anything to try and solve the problem. Instead I will let consumers decide how they want to handle it. Long term, browser dev tools should report an error when the Promise is garbage collected.
Consider this code:
So axios (actually ES6 Promise engine) swallows app errors (which I want to bubble up and crash everything, as it's not runtime error).
http://bahmutov.calepin.co/why-promises-need-to-be-done.html
But looks like
done
still is not a part of spec and "ugly workaround" is required. Some authors insist on deprecatingdone
at all.http://stackoverflow.com/questions/26667598/will-javascript-es6-promise-support-done-api
I'ml aware of all aspects of this subject. What can you propose to solve this issue?
Monkeypatch
.done
? LeavesetTimeout
"trick" as it is? Or there are other ways?The text was updated successfully, but these errors were encountered: