Web: Fix crash that happens when the app receives an unknown message#15087
Web: Fix crash that happens when the app receives an unknown message#15087
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe Changes
Suggested labels
Important Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (1 error)
✅ Passed checks (3 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/app-mobile/utils/ipc/RNToWebViewMessenger.ts`:
- Around line 47-52: The JSON.parse call in RNToWebViewMessenger.ts can throw
for non-JSON payloads before the kind/type guard runs; wrap the non-web branch
parse in a try/catch (or otherwise validate the string) so malformed JSON
doesn't crash: when canUseOptimizedPostMessage is false, attempt
JSON.parse(event.nativeEvent.data) inside a try block, on failure log the raw
payload via logger.info or logger.warn and return early, and only call
this.onMessage(data) when parsing succeeded and the existing typeof data ===
'object' && data !== null && typeof data.kind === 'string' check passes.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 07b91077-9efb-4222-9992-3c0f48ff313b
📒 Files selected for processing (1)
packages/app-mobile/utils/ipc/RNToWebViewMessenger.ts
For example, extensions can send messages which would crash the app because those messages may not have the
.kindproperty