Repository navigation
fix(react): handle restricted localStorage and quota errors in draft storage - #1396
Open
Diwaspant132 wants to merge 2 commits into
Open
Diwaspant132 wants to merge 2 commits into
Diwaspant132 wants to merge 2 commits into
Conversation
…storage - Wrap localStorage access in draftMessage.js with try-catch to prevent SecurityError crashes in cross-origin iframes - Implement in-memory fallback store when localStorage is restricted, disabled, or throws QuotaExceededError - Add optional chaining to RCInstance.getHost() in ChatInput.js to prevent TypeError during uninitialized state - Add unit test suite (7 tests) in draftMessage.test.mjs covering iframe SecurityError, QuotaExceededError, SSR, and draft scoping Signed-off-by: Diwaspant132 <diwaspanta132@gmail.com>
Collaborator
|
hey thanks for picking this up :) |
Author
|
@Aryan-Verma-999 thanks for the review! i've updated the changes with no conflict with base branch |
This branch has not been deployed
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.
fix(react): handle restricted localStorage and quota errors in draft storage
Acceptance Criteria fulfillment
Description
When EmbeddedChat is embedded inside an iframe on third-party sites, modern browsers (Safari, Chrome with partitioned cookies, Brave) restrict access to
window.localStorage, throwing an unhandledSecurityError: Access is denied for this document.Additionally, private browsing mode or storage quotas throwQuotaExceededErroronsetItem.This patch:
try...catchblocks to prevent unhandled runtime crashes in restricted iframes.RCInstance?.getHost?.() || ''inChatInput.jsto avoidTypeErrorwhenRCInstanceis unmounted.packages/react/src/lib/draftMessage.test.mjs(7 unit tests covering basic operations, room/thread/user/host scoping, whitespace handling, iframe SecurityError fallback, QuotaExceededError, and SSR).PR Test Details
Run unit tests:
yarn --cwd packages/react test