promises: `then().catch()` not parsing state correctly
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 21
- Forks
- 23
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 17
Description
Description
When using then().catch() in a job, the state is not passed past the catch() block into the next call.
With the above, the catch block throws an error which should not happen as it has been handled in the block
When a switch is done where we have catch().then(), the catch block handles the error correctly, but state is not passed to the next call.
Example implementation
fn(state => {
if (!state.items) {
console.log('hello error');
throw new Error('No data found');
} else {
console.log('hello success');
console.log({ state });
}
return state;
})
.then(state => {
console.log({ state });
return state;
})
.catch((error, state) => {
console.log({ error });
console.log({ state });
return { error, ...state };
});
Expected Behavior
- Regardless of position, we want the
catch((error, state) => {error, ...state})to effectively handle the error and pass state to the next call.
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 by reproducing the provided then().catch() and catch().then() examples in the promise or job execution path. Trace how errors and state are passed between callbacks; done means catch() handles the error without an unintended throw and preserves state for the next call in either ordering.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100