unwrap gets stuck in errored state and can't recover
#3162
Unanswered
darrenclark
asked this question in
Bug report
Replies: 1 comment 3 replies
-
|
Thanks for reporting. I think the fix makes sense. Please open a PR and see if CI passes. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Bug Description
It seems
unwrapcan get stuck in an errored state and never recover, even if the underlying atom changes to aPromisethat resolves successfully.Cause
jotai/src/vanilla/utils/unwrap.ts
Lines 56 to 62 in 4661064
I think the
const prev = get(promiseAndValueAtom)line will always end up re-throwing the previous error (and it loses the dependency on the underlying atom as well, since it exits beforeconst promise = get(anAtom)on the next line)Potential Solution
Adding a try/catch around it seems to fix the issue, I've got a commit here: darrenclark@3d0ff77 (includes test case that reproduced the issue)
If that fix makes sense, I'll open a PR!
Reproduction Link
darrenclark@3d0ff77
Beta Was this translation helpful? Give feedback.
All reactions