Please note: The following is a problem that behaves differently in different browsers. Perhaps this is a problem with the implementation of the browser. I would love some advice.
In my application, I create a pair of promises that I may not consume until a certain time in the future. What should be good, they promises, after all.
If the remaining promise is resolved, no problem. I can use it as far as possible in the future as I want, and as many times as I want. As expected.
If the pending promise is rejected, however, there is a problem. If I do not take advantage of this rejection shortly after creating it (not sure how soon), a console message will appear in the Chrome or Firefox browser, indicating that there is a fuzzy promise of rejection / error. IE does not cause this error.
So, consider the following code:
console.log("About to make a promise rejection.");
var foo = Promise.reject(new Error("Foo Rejected Promise."));
console.log("Promise rejection made.");
Please note that there is no benefit or consumption of the promise foo. It is just kept for future use.
The console in IE looks like this:
About making promises.
The promised rejection.
Expected. However, the same code in Chrome will give the following console:
About making promises.
The promised rejection.
Unprepared (in promise) Error: Foo The promise was rejected. (...)
Firefox looks just like Chrome, except for the wording around the "uncaught" error.
, "" , , . ..... , .
" " , :
console.log("About to make a promise rejection.");
var foo = Promise.reject(new Error("Foo Rejected Promise."));
console.log("Promise rejection made.");
setTimeout(() => {
foo.catch((err) => {
console.log("Displaying " + err.message + " 10 seconds later.");
});
}, 10000);
"" , - . IE , :
, .
.
Foo . 10 .
Firefox IE .
Chrome :
, .
.
( ) : Foo . (...)
Foo . 10 .
, Chrome , , , .
, , . "" , , :
console.log("About to make a promise rejection.");
var foo = Promise.reject(new Error("Foo Rejected Promise."));
foo.catch(() => { }); // Added this hack-ish code.
console.log("Promise rejection made.");
setTimeout(() => {
foo.catch((err) => {
console.log("Displaying " + err.message + " 10 seconds later.");
});
}, 10000);
.
: , Chrome ( - FireFox), ? . -, , , ?
.