-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Handle exceptions thrown in done handles attached to ProjectManager.getAllFiles #6417
Conversation
… misbehaving done handlers
Reviewing |
You say in the description we currently return a new promise. I think you mean that your PR adds this new behavior right? It looks like the old code would return the same promise for every call. |
// If a done handler attached to the returned filtered files promise | ||
// throws an exception that isn't handled here then it will leave | ||
// _allFilesPromise in an inconsistent state such that no additional | ||
// done handlers will ever be called! |
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.
Maybe I'm reading this in the wrong context...but doesn't this try/catch handle exceptions from done handlers?
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.
This doesn't doesn't directly catch exceptions thrown from the done handlers. But it's possible for an exception handler to throw while flies up through the resolve
call, which breaks that deferred. If we let it go at this point it would also break _allFilesPromise
, which is what we really care about protecting, since that is what's shared.
@iwehrman review complete |
return result; | ||
// If a done handler attached to the returned filtered files promise | ||
// throws an exception that isn't handled here then it will leave | ||
// _allFilesPromise in an inconsistent state such that no additional |
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.
What is _allFilesPromise
? This is the only reference to it I can find.
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.
Typo fixed.
I verified that this fixes the issue. |
…ying to reject the promise, which probably won't work anyway.
@jasonsanjose We do currently return a new promise. That's what the |
Ready for re-review. |
Reviewing again. Looks like the travis error is due to github's services being down. I'll manually run the PR process locally. |
Ah thanks @iwehrman. I see now what you mean about the |
Handle exceptions thrown in done handles attached to ProjectManager.getAllFiles
ProjectManager.getAllFiles
currently returns a new promise to each caller, but if one of the callers attaches a done handler to its promise that throws an exception then no further done handlers attached to later promises returned fromgetAllFiles
are executed. This is because jQuery promises are dumb.Addresses #6401.
CC @redmunds