makeomatic / makeomatic/redux-connect
Handle thrown errors in promise callbacks
Nobody has claimed this yet.
- 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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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