Repository navigation
fix(ui): provide the ssr browser context above ClientContext - #10634
Conversation
PR Summary by QodoWrap ClientContext with the SSR browser provider
AI Description
Diagram
High-Level Assessment
Files changed (1)
|
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTip of the day💡 Did you know, you can show, collapse, or hide each part of a finding: code, evidence, and all Previous reviewsReview updated until commit 3022b2a Results up to commit c17bbe4
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewResults up to commit 3659f7c
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewResults up to commit 5a2cf77
Great, no issues found!Qodo reviewed your code and found no material issues that require review |
…nst it setup_esbuild_bundle now runs `bit build ... --tasks BundleUI,PreBundlePreview` and saves the result to .bundle-cache/ before bundling, so the esbuild bundle ships with a real pre-bundle instead of none at all. e2e_test_esbuild_bundle sets BIT_E2E_UI_MODE=prebuilt so ui-start.e2e.ts/ui-ssr.e2e.ts run for real as part of its normal parallel sweep instead of skipping. Also corrects the known-gaps/findings-log entries: cherry-picked #10634 (the ssr-browser-context fix opened off this branch's SSR-crash finding) does not close that gap - re-tested and the identical crash still reproduces, since our failure goes through a render-plugin context #10634's own description already calls out as not covered. Kept the cherry-pick since it's a correct, verified fix for what it does target.
|
Code review by qodo was updated up to the latest commit 3659f7c |
|
Code review by qodo was updated up to the latest commit c17bbe4 |
|
Code review by qodo was updated up to the latest commit 3022b2a |
useUserAgentreadsssrBrowserContext, and that context is provided in exactly one place — wrapping only{hudItems}and{routes}, insideClientContext. Everything rendered outside that subtree therefore getsundefined, falls back towindow.navigator, and throwsReferenceError: window is not definedon the server. The ssr middleware swallows it and serves the empty client shell, so the page still looks fine in a browser.ClientContextis not a bare provider: it renders icons, the theme switcher, the loader ribbon and the tooltip mount point. Any of those growing auseIsMobilecall — directly or through a dependency bump — takes scope SSR down. Swapping the nesting soSSRBrowserProviderwrapsClientContextcloses the whole class.Why this surfaced now
Reported from a branch that removes core envs from the manifest, where the crash reproduces deterministically:
That branch already has all of #10628's fixes, so this is not a regression of them — it is a second, independent gap that #10628 did not cover. It was latent on
masteronly because nothing insideClientContextcurrently happens to calluseIsMobile; changing which aspects load changes what renders there.Worth being explicit that the
.cjsfix and theuse-user-agentalias from #10628 are still doing their jobs. This is a tree-position bug, not a duplicate-context one — the alias pins the module to a single copy, so provider and consumer share the context object; the consumer is simply rendered where no provider is above it.Proof
Rendering a
TooltipinsideClientContext— what the reporting branch effectively does — and changing nothing else:ui-ssr.e2e.tsClientContext>SSRBrowserProvider(before)#rootempty, ssr fell back to the client shellSSRBrowserProvider>ClientContext(after)The synthetic
Tooltipwas then removed; both UI suites pass on the final diff (16 assertions).Residual gap
Render-plugin
reactContexts (pubsub, lanes, notifications, user-agent) are applied byServerRendereroutside the JSX this file passes, so they remain above the provider. A component rendered by one of those contexts — as opposed to inside its children — would still hit this. Covering that needsssrBrowserContextsupplied as a render plugin rather than as JSX, which is a larger change and not what the reported failure needs.Also worth noting separately:
scopes/ui-foundation/user-agentprovidesuserAgentContext, whichuseUserAgentnever reads — it only readsssrBrowserContext. That aspect looks vestigial for this purpose.