[SITES-35203] fix(host-react): prevent GuestUIFrame crash when guest is undefined - #148
Merged
fe-lix- merged 5 commits intoJul 23, 2026
Conversation
Guard against a missing host or guest before resolving the frame URL and attaching the UI, so an unavailable guest renders null instead of throwing. Hooks now run unconditionally to satisfy the rules of hooks. Add unit tests for GuestUIFrame and a jest moduleNameMapper to strip the ".js" extension from relative imports. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
|
@valeriat-ens I have added some E2E test. |
4 tasks
VladimirZaets
approved these changes
Jul 15, 2026
…ined-guest-crashes-cfe # Conflicts: # e2e/host-app/src/App.js
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.
Jira
SITES-35203
Summary
nullinstead of throwing.GuestUIFrameand a jestmoduleNameMapperto strip the.jsextension from relative imports.Root cause
Reproduction: a local dummy guest extension whose error handler calls
guestConnection.host.modal.close()from within acatchblock (per the example in the ticket):Symptom: calling
host.modal.close()tears down the modal and removes the guest. On the next host render,GuestUIFrameis evaluated while the guest no longer exists, and the host UI crashes instead of unmounting cleanly.Analysis: the failure was not in the extension. In
GuestUIFrame,host.guests.get(guestId)can returnundefined(guest already removed after the modal closed). The component then ran unconditionally:new URL(src, guest.url.href)— throws whenguestisundefined.useEffectdependencies and bodies keyed onguest.id— dereferenceundefined.Because the early
return nullonly covered a missinghost(not a missingguest), an undefined guest threw during render and crashed the subtree instead of degrading gracefully.Fix: resolve the guest defensively (
host ? host.guests.get(guestId) : undefined), key the effects on an optionalguest?.id, gate effect bodies onguestbeing present, and returnnullwhen eitherhostorguestis missing — after the hooks run, to satisfy the rules of hooks.Test plan
npm run test -w packages/uix-host-react(39 passed, incl. 7 newGuestUIFrametests)