Skip to content

Handle rejected promises #104

Open
Open
@yoadsn

Description

@yoadsn

I must be missing something here.
If I return a rejected promise from the loader of a component, nothing seems to work as expected.

On the server side, loadOnServer itself is not rejected but rather it continues to resolve the promise and so the component tree gets rendered without the required data. I then get other exceptions due to the missing data which does reject the entire promise. (as expected).

loadOnServer({ ...renderProps, store }).then(() => {
  // Even when the loader promise is rejected this code runs..
})
.catch(err => {
 // this would run eventually when something breaks in a component due to the missing data..
})

On the client side, I am not even sure what to expect - clearly there is no extension point where I can change the routing and redirect to an error page. How should that be handled on the client?

<ReactReduxProvider store={store}>
  <Router  {...renderProps}
    render={(props) => <ReduxAsyncConnect {...props}
                        render={applyRouterMiddleware(useScroll(cusotmScrollBehaviour))}
                   />}
    routes={getRoutes(context)}/>
</ReactReduxProvider>

Any insights on this would be great (I was digging in the sources for a while, but I don't think there is any special handling for this situation)
Thanks!!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions