azteca69A
tRPC4mo ago
2 replies
azteca69

Stream error polluting sentry - only on Safari

Hi we are using TRPC subscriptions for streaming the LLM response. We've started seeing on error on sentry related to AbortError abort pipeTo from signal.

This errors only happens on safari <16.4, so it matches the chat gpt explanation.

Checking the TRPC repo, found this source code, wondering if I can try catch and ignore this error somewhow.
 ts
  source
    .pipeTo(
      new WritableStream({
        write(chunkOrHead) {
          if (headDeferred) {
            const head = chunkOrHead as Record<number | string, unknown>;

            for (const [key, value] of Object.entries(chunkOrHead)) {
              const parsed = decode(value as any);
              head[key] = parsed;
            }
            headDeferred.resolve(head as THead);
            headDeferred = null;

            return;
          }
          const chunk = chunkOrHead as ChunkData;
          const [idx] = chunk;

          const controller = streamManager.getOrCreate(idx);
          controller.enqueue(chunk);
        },
        close: () => closeOrAbort(new Error('Stream closed')),
        abort: closeOrAbort,
      }),
      {
        signal: opts.abortController.signal,
      },
    )
    .catch((error) => {
      opts.onError?.({ error });
      closeOrAbort(error);
    });
Screenshot_2025-09-11_at_07.47.41.png
Screenshot_2025-09-11_at_07.48.38.png
Was this page helpful?