Skip to content

phoenix.js LongPoll: batchSend timeout leaves awaitingBatchAck stuck — transport buffers all future sends forever #6767

Closed

Description

@rdeese

Environment

  • Phoenix 1.8.5 (phoenix.js), LiveView 1.1.28
  • Observed in production behind enterprise proxies that silently blackhole POST bodies (accepted, never answered)

Summary

In LongPoll.batchSend (assets/js/phoenix/longpoll.js):

batchSend(messages){
  this.awaitingBatchAck = true
  this.ajax("POST", {"Content-Type": "application/x-ndjson"}, messages.join("\n"), () => this.onerror("timeout"), resp => {
    this.awaitingBatchAck = false
    ...

awaitingBatchAck is reset only in the success callback. On the caller-timeout path (onCallerTimeout → this.onerror("timeout")), it is never reset, nothing is retried, and the transport is not closed. From then on, send() takes the else if(this.awaitingBatchAck) branch and appends to batchBuffer forever — a zombie transport that still reports itself open (the GET poll side keeps working) but never delivers another client message, including the channel join.

By contrast, the non-200 response path in the same function correctly calls closeAndRetry.

Reproduction

Proxy that forwards GET /live/longpoll normally but holds POST /live/longpoll forever (no response). The POST XHR times out, onerror("timeout") fires, and the transport silently buffers every subsequent send. The session's polls continue returning empty; the client never joins and never recovers on that transport instance.

Expected

The timeout path should mirror the non-200 path: reset awaitingBatchAck and closeAndRetry, so the socket's normal reconnect/fallback machinery gets a chance.

Real-world impact

Enterprise inspection proxies that hold POST bodies for a verdict that never comes produce exactly this shape. We traced a large customer's users to it in production: GETs flow, the join POST never arrives, and the client sits on a zombie longpoll transport. (LiveView's own join timeout eventually hard-reloads the page, which turns this into a reload loop — but the transport bug stands on its own.)

We have a reproduction harness (node middlebox proxy + Playwright driver) and are happy to share it or test a patch.


Filed on behalf of Rupert Deese by Claude, the AI engineering assistant at Gearflow, which found and verified this during a production transport investigation.

Activity

  1. SteffenDE commented on Jul 28, 2026

    @SteffenDE
    Member

    If your middleboxes fuck up both websockets and longpoll, you’re kind of in a bad spot 😅

    If it holds POST requests, how would reconnecting help? Or does it work sometimes?

  2. rdeese commented on Jul 28, 2026

    @rdeese
    ContributorAuthor

    Rather than argue the point in the abstract, we sent the fix with the argument in the description: #6769

    Short version: it does work sometimes — the case we traced is a dual-WAN site where the router picks a path per connection, so a fresh connection is a fresh draw (one session's POSTs started flowing 8.5 minutes in). And where it genuinely can't help, the fix at least fails loudly instead of freezing silently: today the transport keeps looking open and buffers every send forever, so nothing above it can react.

    A PR for #6766 is up as well: #6768


    Submitted on behalf of Rupert Deese by Claude, the AI engineering assistant at Gearflow.

  3. added a commit that references this issue on Jul 29, 2026
    f5db0fe
  4. added a commit that references this issue on Aug 10, 2026
    b6b77e4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions