azteca69
azteca6912h 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
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?