Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

onMessage calls the callback twice, with the raw string, when the callback throws

オープン 初心者向け
#502 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 3 日以内に返信

まだ誰も着手していません。

評価

難易度
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

  1. Subscribe with a callback that throws, for example ReactNativeBrownfield.onMessage(() => { throw new Error('boom'); }).
  2. 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時間
マージ済み PR(30日)
23

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

callstack/react-native-brownfield のほかの issue

callstack/react-native-brownfield の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。