Core: Add try-catch for cross-origin access in Storybook hooks#33448
Merged
Conversation
|
View your CI Pipeline Execution ↗ for commit 2a10a31
☁️ Nx Cloud last updated this comment at |
valentinpalkovic
approved these changes
Dec 31, 2025
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What I did
I noticed chromatic canvas failing due to a parent.[property] access being denied, due to cross origin.
I suspect this is the culpit of the error, so I'm wrapping the code with a try-catch for now.
I do wonder why this is production code, since the comments imply it's only there for internal e2e testing purposes.
Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
I'll manually check the UI review canvas in chromatic.
This was where I found the error before:
https://www.chromatic.com/component?appId=635781f3500dd2c49e189caf&csfId=manager-sidebar-treenode&specName=Types&buildNumber=24086&k=69499185f7f68d66d9516994-1200px-interactive-true&h=3&b=-1
After this change I can see the canvas corectly, see here:
https://www.chromatic.com/component?appId=635781f3500dd2c49e189caf&csfId=manager-sidebar-treenode&specName=Types&buildNumber=24180&k=69499185f7f68d66d9516994-1200px-interactive-true&h=8&b=-2
So that should no longer happen after this change.
I think we should patch this back, it may also be affecting storybook composition?
If I understand the comment correctly, this code only exists for internal e2e testing purposes.
I suggest we try to find another way to test the behavior without introducing globalThis.parent hooks in the preview runtime code.