This repository was archived by the owner on Jan 1, 2025. It is now read-only.
Repository navigation
Conversation
The creation of a finally branch of the promise causes unhandled promise rejections, despite the fact that the promise is actually handled downstream. This change returns the finally branch instead of the original promise, so there's no divergence in the handling.
Contributor
|
@wd-fb has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
snipershooter0701
pushed a commit
to snipershooter0701/Recoil
that referenced
this pull request
Mar 5, 2023
Summary:
The creation of a finally branch of the promise in `useRecoilCallback` causes unhandled promise rejections, despite the fact that the promise is actually handled downstream. This change returns the finally branch instead of the original promise, so there's no divergence in the handling.
For example, the following selector currently "throws" twice, once caught/logged and once not caught:
```javascript
const testState = selector({
key: 'testState',
get: ({ getCallback }) =>
getCallback(() => async () => {
throw 'test';
}),
});
function Component() {
const test = useRecoilValue(testState);
useEffect(() => {
test().then(
() => console.log('OK'),
(error) => console.log(error),
);
}, [test]);
// ...
}
```
Pull Request resolved: facebookexperimental/Recoil#2075
Reviewed By: drarmstr
Differential Revision: D40573295
Pulled By: wd-fb
fbshipit-source-id: 2683fbb2d881a61ab800c114d0c72997aa25dd3a
eagle2722
added a commit
to eagle2722/Recoil
that referenced
this pull request
Sep 21, 2024
Summary:
The creation of a finally branch of the promise in `useRecoilCallback` causes unhandled promise rejections, despite the fact that the promise is actually handled downstream. This change returns the finally branch instead of the original promise, so there's no divergence in the handling.
For example, the following selector currently "throws" twice, once caught/logged and once not caught:
```javascript
const testState = selector({
key: 'testState',
get: ({ getCallback }) =>
getCallback(() => async () => {
throw 'test';
}),
});
function Component() {
const test = useRecoilValue(testState);
useEffect(() => {
test().then(
() => console.log('OK'),
(error) => console.log(error),
);
}, [test]);
// ...
}
```
Pull Request resolved: facebookexperimental/Recoil#2075
Reviewed By: drarmstr
Differential Revision: D40573295
Pulled By: wd-fb
fbshipit-source-id: 2683fbb2d881a61ab800c114d0c72997aa25dd3a
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The creation of a finally branch of the promise in
useRecoilCallbackcauses unhandled promise rejections, despite the fact that the promise is actually handled downstream. This change returns the finally branch instead of the original promise, so there's no divergence in the handling.For example, the following selector currently "throws" twice, once caught/logged and once not caught: