Skip to content

Upgrade Tesla to 1.18.x to handle Finch streaming transport errors #4781

@elias-ba

Description

@elias-ba

What's broken

Tesla.Adapter.Finch.stream/3 in tesla 1.15.3 only pattern-matches {:ok, _acc} and {:error, error} from Finch.stream/5. Finch can also return {:error, error, partial_acc} (a 3-tuple) when a transport error happens mid-stream. The Tesla streaming Task raises CaseClauseError, the linked Oban worker receives an EXIT signal, and the AI Assistant message-processing job dies abruptly.

How it surfaced

Apollo's SSE connection to Lightning dropped mid-stream on staging, partway through content_block_delta events. Logs show:

** (CaseClauseError) no case clause matching: {:error, %Finch.TransportError{reason: :closed, source: %Mint.TransportError{reason: :closed}}, {#Reference<...>, {:data, "event: content_block_delta\n..."}}}
    (tesla 1.15.3) lib/tesla/adapter/finch.ex:120: anonymous fn/6 in Tesla.Adapter.Finch.stream/3

This is the trigger for the broader incident tracked in #4780. The companion fix on our side (#4780) makes recovery work gracefully even when the underlying call crashes, but the crash itself is unnecessary once Tesla is upgraded.

What to fix

Upstream Tesla shipped the relevant fixes in 1.16.0 (released 2026-01-01):

Latest stable is 1.18.2 (2026-05-15). Bumping mix.exs from "~> 1.15.3" to "~> 1.18" should pick up the fix. A quick audit of our Tesla usage (Lightning.ApolloClient plus anywhere else we instantiate a Tesla.Client) is needed to confirm no behaviour changes affect us; the 1.16/1.17/1.18 release notes look uneventful for our code paths.

Metadata

Metadata

Assignees

No one assigned

    Labels

    AIbugNewly identified bugdependenciesPull requests that update a dependency fileelixirPull requests that update Elixir code

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    New Issues

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions