Skip to content

iOS crashes due to "Promise.allSettled is not a function" #127

Closed

Description

@AndrewGable

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)

Activity

  1. added this to the Alpha Launch milestone on Aug 13, 2020
  2. tgolen commented on Aug 13, 2020

    @tgolen
    Contributor

    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?

  3. AndrewGable commented on Aug 13, 2020

    @AndrewGable
    ContributorAuthor

    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?

  4. tgolen commented on Aug 13, 2020

    @tgolen
    Contributor

    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;
    }
    

    What do you think?

  5. AndrewGable commented on Aug 13, 2020

    @AndrewGable
    ContributorAuthor

    I like it 👍

  6. self-assigned this
    on Aug 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions