-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
7 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
3f32632
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. What's the reason? It seems like trapping the exception in the current tick would be sufficient, since
deferred
will guarantee next tick for resolution, rejection, and progress updates. It also seems like the call tothenable.then
and the priorisPromise
check during assimilation should be done in the same tick (as each other) to prevent interleaving code from adding/removing athen
method.3f32632
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I "feel" that
Q(fakeThenable)
should throw, and not to return a rejection.What about moving
deferred.resolve
in atry..catch
(inwhen
) instead?3f32632
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@briancavalier I am somewhat confused by this myself as well, but @erights insists this is necessary and managed to convince me---I just forgot how. (I think he pointed out the interleaving problem you give as well, however.) @kriskowal probably remembers better.
@rkatic one of the primary use cases for
Q
assimilation is passing untrusted objects or thenables, and getting back a trusted Q promise. If these untrusted objects were malicious and wanted to crash our program or interrupt the control flow of the current turn by throwing, we should not allow this; we do so by usingnextTick
and transforming throws into rejections.3f32632
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, thanks @domenic. If you happen to remember, I'd def be interested to know the reasoning, as it's not obvious to me yet (but I'll keep noodling on it). Maybe @erights or @kriskowal could chime in quickly?
3f32632
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@domenic I am aware that the exception should be caught to propagate exceptions, that's why I am asking what about catching in
when
, instead on coercing itself.3f32632
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@domenic I think this is why, but maybe there are better/other reasons.
3f32632
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.