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.
Staged on #9696
closes: #XXXX
refs: #XXXX
Description
@mhofman 's comment at #9696 (comment) indicated a puzzling rejection in a place that should not happen. If the code were correct, this extra
.catch(reject)
should not have been necessary, and should never do anything. The flaw in when.js is caused by theawait
at the top ofThe problem is that if that onRejected clause happens, it throws
e
. That should be fine, because it is in athen
which will turn that throw into a rejected promise. However theawait
at the top of the above snippet turns it back into a thrown error.This PR does not remove that
await
. That turned out to be trickier than I expected. Rather, it surrounds most of thewhen
code with atry/catch
, turning any error thrown in the body into a call to theonRejected
callback if present.Reviewers, please review with whitespace differences turned off. Or, @turadg , feel free to simply merge this PR into your #9696.
Security Considerations
none beyond the usual: Correct code is better for security than incorrect code.
Scaling Considerations
none
Documentation Considerations
none
Testing Considerations
Would be good for this to be caught by a vow test. Attn @michaelfig
Upgrade Considerations
none