Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

race condition in $mdToast show/hide #9166

Closed
tlaytongoogle opened this issue Jul 28, 2016 · 2 comments
Closed

race condition in $mdToast show/hide #9166

tlaytongoogle opened this issue Jul 28, 2016 · 2 comments
Assignees
Labels
g3: reported The issue was reported by an internal or external product team. P1: urgent Urgent issues that should be addressed in the next minor or patch release.
Milestone

Comments

@tlaytongoogle
Copy link

Actual Behavior:

  • What is the issue? *
  • There seems to a race condition in $mdToast. If $mdToast.show() is called, and then $mdToast.hide() is called a sufficiently short time later, then hide() will execute before show() has actually generated the toast DOM, and thus will fail to actually hide the toast.
  • This issue is exacerbated if show() is called while a previous toast is still being displayed, because the time taken to hide the previous toast further delays the generation of the new toast DOM.
  • The issue seems to be the result of this line:
    hideExisting.finally(function() {
    . Specifically, the fact that the DOM manipulation is performed asynchronously there, but the surrounding show() method does not wait for that asynchronous operation to complete before returning, nor does it return the resulting promise so that the calling code can wait (it does return a promise, but tied to a different event).
  • Moreover, because this line is in interimElement.js, it's possible that it affects other services than just $mdToast (e.g. $mdDialog), although I haven't tested for that.
  • What is the expected behavior? hide() should hide the toast as long as it's called after show(), even if immediately after.

CodePen (or steps to reproduce the issue): *

  • CodePen Demo which shows your issue: http://codepen.io/anon/pen/jAKgEZ
  • Details: See the CodePen for information about what specific circumstances do and do not run afoul of the race condition.

Angular Versions: *

  • Angular Version: 1.4.8
  • Angular Material Version: 1.0.0

Additional Information:

  • Browser Type: * Chrome
  • Browser Version: * 52.0
  • OS: * Linux
@jelbourn jelbourn added g3: reported The issue was reported by an internal or external product team. P1: urgent Urgent issues that should be addressed in the next minor or patch release. labels Jul 28, 2016
@devversion devversion self-assigned this Jul 29, 2016
@devversion
Copy link
Member

@ThomasBurleson @jelbourn - This can be super easily solved after #9053

@devversion devversion added the Blocked Progress on this issue is blocked. Primarily used for PRs that are blocked by presubmit feedback. label Jul 30, 2016
@ThomasBurleson ThomasBurleson modified the milestone: 1.1.1 Aug 22, 2016
@devversion devversion removed the Blocked Progress on this issue is blocked. Primarily used for PRs that are blocked by presubmit feedback. label Sep 21, 2016
@devversion
Copy link
Member

This is now fixed in master with 421fed4

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
g3: reported The issue was reported by an internal or external product team. P1: urgent Urgent issues that should be addressed in the next minor or patch release.
Projects
None yet
Development

No branches or pull requests

4 participants