onMessage calls the callback twice, with the raw string, when the callback throws
維護者通常 3 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 新手友好度
- 85/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
- 技術堆疊
- react-native, typescript
- 領域
- mobile
研究方向
從 packages/react-native-brownfield/src/index.ts 中的 ReactNativeBrownfield.onMessage 開始,檢查解析錯誤和回呼錯誤的處理方式。使用一則有效的 JSON 訊息和一個會丟出錯誤的回呼來重現;完成的標準是回呼使用解析後的資料執行一次,且其原始錯誤會浮現。
由索引模型根據 Issue 內容生成。
描述
ReactNativeBrownfield.onMessage in packages/react-native-brownfield/src/index.ts calls the callback inside the same try block as JSON.parse:
try {
callback({ data: JSON.parse(payload.text) });
} catch {
callback({ data: payload.text });
}
If the callback throws while it handles a valid JSON message, the catch branch runs the callback again with the unparsed string as data, and the original error is discarded.
Steps to reproduce
- Subscribe with a callback that throws, for example
ReactNativeBrownfield.onMessage(() => { throw new Error('boom'); }). - From the native host, post a JSON message such as
{"type":"login"}.
Expected behavior
The callback runs once with data set to { type: 'login' }, and the boom error surfaces.
Actual behavior
The callback runs twice: first with { type: 'login' }, then with the string '{"type":"login"}'. The boom error from the first call is swallowed. Handlers that are not idempotent run their side effects twice, and the second call usually fails with a different, misleading error.
- 主要語言
- TypeScript
- 星號
- 552
- 分支
- 53
- 平均合併
- 3 天 8 小時
- 30 天內合併 PR
- 23
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
callstack/react-native-brownfield 的其他 Issue
-
難度 4/5 3-5 天 新手友好度 45/100
callstack/react-native-brownfield#499 ·
維護者通常 3 天內回覆
-
難度 4/5 3-5 天 新手友好度 48/100
callstack/react-native-brownfield#498 ·
維護者通常 3 天內回覆
-
難度 4/5 3-5 天 新手友好度 55/100
callstack/react-native-brownfield#468 ·
維護者通常 3 天內回覆
-
難度 4/5 3-5 天 新手友好度 48/100
callstack/react-native-brownfield#420 ·
維護者通常 3 天內回覆
-
難度 5/5 一週以上 新手友好度 38/100
callstack/react-native-brownfield#406 ·
維護者通常 3 天內回覆
查看 callstack/react-native-brownfield 的全部 Issue
相似的 Issue
-
area: app type: bug
難度 2/5 1-3 小時 新手友好度 78/100
ExpidetGames/code-reviewer#585 ·
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 83/100
module-federation/core#5205 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 73/100
LanternOps/breeze#9392 · 1 則留言 ·
維護者通常 1 天內回覆
-
engine-rs P3 review-deferral wasm
難度 2/5 1-3 小時 新手友好度 77/100
maniator/verticopolis#1154 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆