Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 2, 2025

In production builds with streaming, getPageContext({ asyncHook: true }) was returning a different proxy object than usePageContext(), causing assertion failures in tests.

Root cause: The sync hook's globalObject.pageContext is cleared on the next microtask. When React renders asynchronously, the async hook fallback was creating a new proxy instead of returning the cached one.

Changes

  • Store proxy in async store during hook execution (execHook.ts): The proxied pageContext is now stored in _asyncStore.pageContext when hooks execute, ensuring the same proxy is available later.

  • Return cached proxy if available (getHttpRequestAsyncStore.ts): Check _isProxyObject before creating a new proxy; return the stored proxy directly if already proxied.

  • Type-safe helper function: Extracted storeProxyInAsyncStore() with proper type guard to avoid duplication and as any casts.

// Test expectation that now passes
const pageContext = usePageContext()
const pageContext2 = getPageContext({ asyncHook: true })
assert(pageContext2 === pageContext) // ✓ Same object reference

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copy link
Contributor Author

Copilot AI commented Dec 2, 2025

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • star-wars.brillout.com
    • Triggering command: /usr/local/bin/node node scripts/build.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Refactor async store for improved functionality Fix getPageContext({ asyncHook: true }) returning different proxy than usePageContext() Dec 2, 2025
Copilot AI requested a review from brillout December 2, 2025 22:15
Copilot finished work on behalf of brillout December 2, 2025 22:15
@brillout brillout force-pushed the brillout/dev branch 2 times, most recently from dac7903 to 4c63951 Compare December 3, 2025 10:03
@brillout brillout closed this Dec 3, 2025
@brillout brillout deleted the copilot/sub-pr-2877 branch December 3, 2025 17:29
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.

2 participants