Skip to content

Fix: #198 - Error thrown in ngOnDestroy if plot not yet initialized #246

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 7, 2023

Conversation

paulirwin
Copy link
Contributor

This can occur in unit tests if you do not await the component being stable, so this resolves #198. However, this could also happen if ngOnDestroy is called very quickly after ngOnInit.

Note that the actual error happens inside createFigure, but given that the PlotlyService.remove call needs the plotlyInstance as well, and that other code checks plotlyInstance for truthiness first, this seemed like a reasonable seam to introduce this check.

The provided unit test failed before making this change, so this PR was done via TDD.

One bonus of this change is that it removes a use of the ! operator.

…ized

This can occur in unit tests if you do not await the component being
stable, so this resolves plotly#198. However, this could also happen if
ngOnDestroy is called very quickly after ngOnInit.
@andrefarzat andrefarzat merged commit 1f9da25 into plotly:master Aug 7, 2023
@andrefarzat
Copy link
Collaborator

Thank you, @paulirwin 😸

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Angular 13: Errors when running Unit Tests
2 participants