makeomatic / makeomatic/redux-connect

Handle thrown errors in promise callbacks

Open
#108 4 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement help wanted
Dominant language
JavaScript
Stars
545
Forks
61
PR merge metrics
No merged PRs in 30d

Description

This [line of code](https://github.com/makeomatic/redux-connect/blob/b4bc64e9b256cced2628ce72dbffa7fdf2cbc5bc/modules/helpers/utils.js#L133) does not catch errors so instead they get lost in the event loop and the component never gets rendered correctly. Additionally, it's hard to catch and display the error in an isomorphic app.

Something like this would reproduce it:
````js
@asyncConnect([{
deferred: true,
promise: () => {
throw new Error('whoops, this was not supposed to happen');
},
}])
class SomeComponent extends React.Component {
...
}
````
It should be fixable like this:
````js
let promiseOrResult;
try {
promiseOrResult = item.promise(rest);
} catch (error) {
promiseOrResult = Promise.reject(error);
}
````

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in modules/helpers/utils.js at the linked line and trace how item.promise(rest) is handled for deferred async props. Use the provided throwing callback as the reproduction case, then verify that the error reaches the app's rendering or error-handling path instead of being lost in the event loop.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
full-stack
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.