azteca69
azteca694w ago

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);
});
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);
});
No description
No description
1 Reply
CharlieCrisp
CharlieCrisp2d ago
We see a lot of these errors on sentry too! I would be very grateful for a fix.

Did you find this page helpful?