Skip to content

Core: Add try-catch for cross-origin access in Storybook hooks#33448

Merged
ndelangen merged 1 commit into
nextfrom
norbert/fix-globalthis-parent-access
Dec 31, 2025
Merged

Core: Add try-catch for cross-origin access in Storybook hooks#33448
ndelangen merged 1 commit into
nextfrom
norbert/fix-globalthis-parent-access

Conversation

@ndelangen
Copy link
Copy Markdown
Member

@ndelangen ndelangen commented Dec 31, 2025

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:

  • stories
  • unit tests
  • integration tests
  • end-to-end 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.

@ndelangen ndelangen self-assigned this Dec 31, 2025
@ndelangen ndelangen added bug patch:yes Bugfix & documentation PR that need to be picked to main branch core preview-api ci:normal labels Dec 31, 2025
@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Dec 31, 2025

View your CI Pipeline Execution ↗ for commit 2a10a31

Command Status Duration Result
nx run-many -t compile,check,knip,test,pretty-d... ✅ Succeeded 10m 38s View ↗

☁️ Nx Cloud last updated this comment at 2025-12-31 09:48:21 UTC

@ndelangen ndelangen merged commit fe9738e into next Dec 31, 2025
80 of 85 checks passed
@ndelangen ndelangen deleted the norbert/fix-globalthis-parent-access branch December 31, 2025 12:07
@ndelangen ndelangen removed the patch:yes Bugfix & documentation PR that need to be picked to main branch label Dec 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants