bug: Chat transport crashes on Safari < 17.4: AbortSignal.any is not a function

Offen Anfängerfreundlich
#5,098 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

  • #5100 von @cocvn157 — ohne Merge geschlossen
  • #5107 von @ghazy2001 — ohne Merge geschlossen

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
83/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv

Rechercherichtung

Lies zuerst v3/sessions.js, das der Issue als bestehendes Beispiel für die Absicherung von AbortSignal.any nennt. Untersuche anschließend die drei Aufrufstellen des Chat-Transports in dist/esm/v3/chat.js und dist/esm/v3/chat-client.js sowie deren CommonJS-Builds. Entferne zum Reproduzieren AbortSignal.any und führe send und die Fortsetzung eines Streams aus; fertig ist die Arbeit, wenn beides ohne die Methode funktioniert und das bestehende Verhalten weiterhin abgedeckt ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Provide environment information
System:
  OS: macOS 27.0.1
  CPU: (12) arm64 Apple M4 Pro
  Memory: 24.00 GB
  Shell: 5.9 - zsh
Binaries:
  Node: 24.12.0
  npm: 11.6.2
  pnpm: 10.33.0
  bun: 1.3.7

Affected client (end user's browser):
Safari 17.2.1 on macOS (Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2.1 Safari/605.1.15)

Packages:
@trigger.dev/sdk 4.8.3 (also reproduced on 4.7.3)
ai 7.0.162
next 16 (App Router), React 19

Describe the bug

The browser-side chat transport (useTriggerChatTransport from @trigger.dev/sdk/chat/react) calls AbortSignal.any without checking that it exists. Safari only added AbortSignal.any in 17.4, so on Safari 17.0–17.3 (and 16.x) every chat request throws:

TypeError: AbortSignal.any is not a function. (In 'AbortSignal.any([t,o.signal])', 'AbortSignal.any' is undefined)
at subscribeToSessionStream

The AI SDK always passes an abortSignal to sendMessages / reconnectToStream, so the AbortSignal.any branch is hit on every send and every resume. Chat is unusable for these users.

Next.js supports Safari 16.4+ by default, so these browsers are still in the supported range for most apps using the SDK.

Unguarded call sites in 4.8.3:

  • dist/esm/v3/chat.js:614 (reconnectToStream)
  • dist/esm/v3/chat.js:1210 (subscribeToSessionStream)
  • dist/esm/v3/chat-client.js:571
    (and the matching commonjs builds)
Reproduction repo

No standalone repo. Any app that uses useTriggerChatTransport with useChat reproduces it on Safari < 17.4, or on any browser after removing the method (see steps below).

To reproduce
  1. Set up a chat using useTriggerChatTransport from @trigger.dev/sdk/chat/react with useChat from @ai-sdk/react.
  2. Open the app in Safari 17.2 (or any Safari < 17.4).
    Alternatively, in any modern browser, run delete AbortSignal.any in the devtools console before the chat mounts.
  3. Send a message, or reload a page with an active chat so it resumes the stream.
  4. The transport throws TypeError: AbortSignal.any is not a function and the chat request fails.
Suggested fix

v3/sessions.js already guards this for Node 18 (if (typeof AbortSignal.any === "function") ... else { wire the caller signal manually }). Applying the same guard, or a small shared helper, to the chat transport would fix it. For example:

function anySignal(signals: AbortSignal[]): AbortSignal {
  if (typeof AbortSignal.any === "function") return AbortSignal.any(signals);

  const controller = new AbortController();
  const aborted = signals.find((s) => s.aborted);
  if (aborted) {
    controller.abort(aborted.reason);
    return controller.signal;
  }

  for (const s of signals) {
    s.addEventListener("abort", () => controller.abort(s.reason), {
      once: true,
      signal: controller.signal,
    });
  }
  return controller.signal;
}

and use it at the three call sites in chat.js and chat-client.js.

Additional information

We've worked around it on our side by polyfilling AbortSignal.any in instrumentation-client.ts. It would still be good to fix in the SDK, since apps using the chat transport won't know they need the polyfill until older-Safari users report broken chat.

Vorherrschende Sprache
TypeScript
Sterne
16.5k
Forks
1.5k
Ø Merge
1 T. 15 Std.
Gemergte PRs (30 T.)
17

Entwicklungsumgebung

Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus triggerdotdev/trigger.dev

Alle Issues in triggerdotdev/trigger.dev

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.