Binary pushes don't work over the LongPoll transport

オープン
#6,906 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

@mandar1045 がすでに取り組んでいます。

2026年11月14日 から。

  • #6907 @mandar1045 による — オープン

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
elixir, javascript
領域
backend

調査の方向性

Start with Phoenix.Transports.LongPoll.Server, where the {:push, ...} and {:reply, ...} clauses drop the frame opcode before buffering, and with the LongPoll client path in longpoll.js that parses the messages list. Run the LongPoll transport tests and add a case that pushes {:binary, <<255,1,2>>} then another message, checking the poll returns both without a 500 and the client parses them. Done means binary server-to-client frames round-trip over LongPoll as they do over WebSocket; note #6907 already proposes a base64 approach, so review it first.

索引モデルが issue の本文から書いたものです。

説明

Pushing binary data from a channel doesn't work when the client is on the LongPoll transport.

def handle_info(:send_bin, socket) do
  push(socket, "bin", {:binary, <<255, 1, 2>>})
  {:noreply, socket}
end

Over WebSocket this works fine. Over LongPoll:

  • if the data is not valid UTF-8, the poll request fails with a 500 ({:invalid_byte, 255} from the JSON encoder), and since the server already cleared its buffer, every other buffered message in that poll is lost too (including the join reply in my test)
  • if the data happens to be valid UTF-8, the raw binary frame ends up as a string in the messages list, e.g. "\u0000\u0001\u0006\u00031room:xbinhello", and phoenix.js fails trying to JSON.parse it

Looks like Phoenix.Transports.LongPoll.Server drops the opcode ({:push, {_, reply}, state} / {:reply, status, {_, reply}, state}) and buffers the binary as if it was text. Client to server binary over LongPoll is already handled (base64 encoded, from #5513), but the server to client direction isn't.

One option would be to base64 encode binary frames on the server like the upload path does, and have longpoll.js decode them before handing them to the socket.

主要言語
Elixir
スター
23.2k
フォーク
3.2k
平均マージ
16時間 35分
マージ済み PR(30日)
18

環境構築

はじめの一歩

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

phoenixframework/phoenix のほかの issue

phoenixframework/phoenix の issue をすべて見る

似ている issue

Elixir の issue をもっと見る

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

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