Components: MatDialog unresponsive when opened from ErrorHandler with error from async method

Created on 8 Aug 2019  路  3Comments  路  Source: angular/components

Reproduction

StackBlitz example: https://stackblitz.com/edit/components-issue-h6h2vv

Steps to reproduce:

  1. Provide global error handler for angular
  2. Throw any Error within async function

Expected Behavior

The lifecycle of the dialog should be triggered and the dialog should display the information

Actual Behavior

The only thing from the dialog class called is the constructor, everything else is not called and the dialog cannot be closed

Environment

  • Angular: 7.2.2
  • CDK/Material: 7.2.2
  • Browser(s): Google Chrome, StackBlitz
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows

Comment

When I tried it out on my environment, I found out that any resize event (maybe other events too) trigger the lifecycle of the component, it updates and works fine.
On StackBlitz though the events are not triggered in any case, it just renders the app totally unresponsive

So my current solution to this is - dispatching resize event right after opening the dialog, which makes it work fine, but I have no idea why is it failing to trigger the onInit etc. by itself.

Also no .onOpen() or .onOpened() subscriptions emit any data before resize event

Most helpful comment

It sounds like the dialog is opened outside of the NgZone. Have you tried calling dialog.open from inside of NgZone.run?

All 3 comments

It sounds like the dialog is opened outside of the NgZone. Have you tried calling dialog.open from inside of NgZone.run?

@crisbeto NgZone.run seems to fix it. So I guess that solves the issue
https://stackblitz.com/edit/components-issue-2yurh6

Why is it run out of the NgZone like that though?

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alanpurple picture alanpurple  路  3Comments

michaelb-01 picture michaelb-01  路  3Comments

MurhafSousli picture MurhafSousli  路  3Comments

LoganDupont picture LoganDupont  路  3Comments

constantinlucian picture constantinlucian  路  3Comments