Skip to content

fix(workbench): guard BannerPart.show against calls before createContentArea (#310358)#310825

Open
maruthang wants to merge 1 commit intomicrosoft:mainfrom
maruthang:fix/issue-310358-bannerpart-show-guard
Open

fix(workbench): guard BannerPart.show against calls before createContentArea (#310358)#310825
maruthang wants to merge 1 commit intomicrosoft:mainfrom
maruthang:fix/issue-310358-bannerpart-show-guard

Conversation

@maruthang
Copy link
Copy Markdown
Contributor

WhatBannerPart.show() now no-ops when the banner hasn't been rendered yet, instead of throwing on clearNode(undefined).

WhyWorkspaceTrustManagementService.onDidChangeTrust can fire its subscriber (which calls BannerPart.show()) during startup before createContentArea() runs. The first line of show() dereferences this.element, producing TypeError: Cannot read properties of undefined (reading 'firstChild') (#310358).

How — Added if (!this.element) return; at the top of show(). Once the banner is rendered, behavior is unchanged.

Test plan — New bannerPart.test.ts instantiates BannerPart, calls show(...) before create(...), and asserts no throw. Pre-fix this failed with clearNode(undefined).

Fixes #310358

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.

[Error] unhandlederror-Cannot read properties of undefined (reading 'firstChild')

2 participants