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
{{ message }}
Repository navigation
iOS crashes due to "Promise.allSettled is not a function" #127
cc @tgolen - Also due to #111 I should have tested on iOS sorry 😆
[Wed Aug 12 2020 18:16:40.759] ERROR TypeError: Promise.allSettled is not a function. (In 'Promise.allSettled(reportFetchPromises)', 'Promise.allSettled' is undefined)
This error is located at:
in WithIon (at HomePage.js:40)
in RCTView (at View.js:34)
in View (at HomePage.js:39)
in Route (at HomePage.js:38)
in RCTView (at View.js:34)
in View (at HomePage.js:37)
in RCTSafeAreaView (at SafeAreaView.js:51)
in ForwardRef(SafeAreaView) (at HomePage.js:36)
in App (created by Context.Consumer)
in Route (at Expensify.js:33)
in Switch (at Expensify.js:31)
in Router (created by MemoryRouter)
in MemoryRouter (at NativeRouter.js:11)
in NativeRouter (at Expensify.js:27)
in Expensify (at WithIon.js:144)
in WithIon (at App.js:4)
in _default (at renderApplication.js:45)
in RCTView (at View.js:34)
in View (at AppContainer.js:106)
in RCTView (at View.js:34)
in View (at AppContainer.js:132)
in AppContainer (at renderApplication.js:39)
I looked into it an it looked like this is a pretty new function, right? I can't exactly tell what version of JavaScript the simulator is running, so it was hard for me to tell. Can we use Promise.all() instead? Do we care about the return value of each Promise or just the overall result of them all?
Well, I don't know how new it is, but I found newer methods (like .any()). .all() cannot be used because of this:
It rejects immediately upon any of the input promises rejecting
so we basically have to write our own implementation of allSettled()...
This is what I'm thinking.
/**
* Returns a promise that is resolved when all arrayOfPromises are either resolved or rejected
*/
function promiseAllSettled(arrayOfPromises) {
const mainPromise = new Promise((resolve) => {
const done = _.after(arrayOfPromises.length, resolve);)
_.each(arrayOfPromises, (promise) => {
promise.then(done).catch(done);
});
});
return mainPromise;
}
Activity
tgolen commentedon Aug 13, 2020
What?! That's pretty odd that it's not supported. There looks to be really good browser support on it https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/allSettled
Do you know what methods are available?
AndrewGable commentedon Aug 13, 2020
I looked into it an it looked like this is a pretty new function, right? I can't exactly tell what version of JavaScript the simulator is running, so it was hard for me to tell. Can we use
Promise.all()instead? Do we care about the return value of eachPromiseor just the overall result of them all?tgolen commentedon Aug 13, 2020
Well, I don't know how new it is, but I found newer methods (like
.any())..all()cannot be used because of this:so we basically have to write our own implementation of
allSettled()...This is what I'm thinking.
What do you think?
AndrewGable commentedon Aug 13, 2020
I like it 👍