@trpc/server
Advanced tools
Comparing version 11.0.0-rc.553 to 11.0.0-rc.560
{ | ||
"bundleSize": 136392, | ||
"bundleOrigSize": 182813, | ||
"bundleReduction": 25.39, | ||
"bundleSize": 136868, | ||
"bundleOrigSize": 183401, | ||
"bundleReduction": 25.37, | ||
"modules": [ | ||
@@ -17,3 +17,3 @@ { | ||
], | ||
"percent": 13.52, | ||
"percent": 13.47, | ||
"reduction": 0 | ||
@@ -35,3 +35,3 @@ }, | ||
], | ||
"percent": 12.88, | ||
"percent": 12.83, | ||
"reduction": 4.31 | ||
@@ -52,3 +52,3 @@ }, | ||
], | ||
"percent": 11.94, | ||
"percent": 11.9, | ||
"reduction": 0 | ||
@@ -68,3 +68,3 @@ }, | ||
], | ||
"percent": 5.64, | ||
"percent": 5.62, | ||
"reduction": 0 | ||
@@ -87,3 +87,3 @@ }, | ||
], | ||
"percent": 4.71, | ||
"percent": 4.69, | ||
"reduction": 40.09 | ||
@@ -93,4 +93,4 @@ }, | ||
"id": "/src/unstable-core-do-not-import/stream/sse.ts", | ||
"size": 5910, | ||
"origSize": 6971, | ||
"size": 6386, | ||
"origSize": 7559, | ||
"renderedExports": [ | ||
@@ -106,4 +106,4 @@ "sseStreamProducer", | ||
], | ||
"percent": 4.33, | ||
"reduction": 15.22 | ||
"percent": 4.67, | ||
"reduction": 15.52 | ||
}, | ||
@@ -122,3 +122,3 @@ { | ||
], | ||
"percent": 4.25, | ||
"percent": 4.23, | ||
"reduction": 64.74 | ||
@@ -137,3 +137,3 @@ }, | ||
], | ||
"percent": 3.97, | ||
"percent": 3.96, | ||
"reduction": 11.38 | ||
@@ -158,3 +158,3 @@ }, | ||
], | ||
"percent": 3.02, | ||
"percent": 3.01, | ||
"reduction": 0 | ||
@@ -173,3 +173,3 @@ }, | ||
], | ||
"percent": 2.36, | ||
"percent": 2.35, | ||
"reduction": 22.57 | ||
@@ -188,3 +188,3 @@ }, | ||
], | ||
"percent": 2.1, | ||
"percent": 2.09, | ||
"reduction": 6.07 | ||
@@ -205,3 +205,3 @@ }, | ||
], | ||
"percent": 2.02, | ||
"percent": 2.01, | ||
"reduction": 0 | ||
@@ -226,3 +226,3 @@ }, | ||
], | ||
"percent": 2.01, | ||
"percent": 2, | ||
"reduction": 45.94 | ||
@@ -241,3 +241,3 @@ }, | ||
], | ||
"percent": 1.98, | ||
"percent": 1.97, | ||
"reduction": 40.98 | ||
@@ -262,3 +262,3 @@ }, | ||
], | ||
"percent": 1.93, | ||
"percent": 1.92, | ||
"reduction": 55.78 | ||
@@ -279,3 +279,3 @@ }, | ||
], | ||
"percent": 1.71, | ||
"percent": 1.7, | ||
"reduction": 0 | ||
@@ -309,3 +309,3 @@ }, | ||
], | ||
"percent": 1.61, | ||
"percent": 1.6, | ||
"reduction": 13.79 | ||
@@ -374,3 +374,3 @@ }, | ||
"dependents": [], | ||
"percent": 1.25, | ||
"percent": 1.24, | ||
"reduction": 19.29 | ||
@@ -454,2 +454,3 @@ }, | ||
"/src/unstable-core-do-not-import/http/resolveResponse.ts", | ||
"/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts", | ||
"/src/unstable-core-do-not-import/error/TRPCError.ts", | ||
@@ -459,3 +460,2 @@ "/src/unstable-core-do-not-import/transformer.ts", | ||
"/src/unstable-core-do-not-import/router.ts", | ||
"/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts", | ||
"/src/unstable-core-do-not-import/http/contentType.ts", | ||
@@ -511,3 +511,3 @@ "/src/unstable-core-do-not-import/procedureBuilder.ts", | ||
], | ||
"percent": 0.78, | ||
"percent": 0.77, | ||
"reduction": 0 | ||
@@ -576,3 +576,3 @@ }, | ||
"dependents": [], | ||
"percent": 0.56, | ||
"percent": 0.55, | ||
"reduction": 66.9 | ||
@@ -662,3 +662,3 @@ }, | ||
"dependents": [], | ||
"percent": 0.21, | ||
"percent": 0.2, | ||
"reduction": 72.92 | ||
@@ -752,5 +752,5 @@ }, | ||
{ | ||
"id": "/src/index.ts", | ||
"id": "/src/rpc.ts", | ||
"size": 0, | ||
"origSize": 32, | ||
"origSize": 36, | ||
"renderedExports": [], | ||
@@ -763,5 +763,5 @@ "removedExports": [], | ||
{ | ||
"id": "/src/shared.ts", | ||
"id": "/src/index.ts", | ||
"size": 0, | ||
"origSize": 653, | ||
"origSize": 32, | ||
"renderedExports": [], | ||
@@ -774,5 +774,5 @@ "removedExports": [], | ||
{ | ||
"id": "/src/rpc.ts", | ||
"id": "/src/shared.ts", | ||
"size": 0, | ||
"origSize": 36, | ||
"origSize": 653, | ||
"renderedExports": [], | ||
@@ -820,2 +820,12 @@ "removedExports": [], | ||
{ | ||
"id": "/src/adapters/fastify/index.ts", | ||
"size": 0, | ||
"origSize": 78, | ||
"renderedExports": [], | ||
"removedExports": [], | ||
"dependents": [], | ||
"percent": 0, | ||
"reduction": 100 | ||
}, | ||
{ | ||
"id": "/src/adapters/fetch/index.ts", | ||
@@ -844,12 +854,2 @@ "size": 0, | ||
"reduction": 100 | ||
}, | ||
{ | ||
"id": "/src/adapters/fastify/index.ts", | ||
"size": 0, | ||
"origSize": 78, | ||
"renderedExports": [], | ||
"removedExports": [], | ||
"dependents": [], | ||
"percent": 0, | ||
"reduction": 100 | ||
} | ||
@@ -856,0 +856,0 @@ ], |
@@ -57,5 +57,6 @@ import type { ConsumerOnError } from './jsonl'; | ||
export declare function sseStreamConsumer<TData>(opts: { | ||
from: EventSource; | ||
from: Pick<EventSource, 'addEventListener' | 'readyState'>; | ||
onError?: ConsumerOnError; | ||
deserialize?: Deserialize; | ||
tryHandleError?: (error: Event) => Promise<boolean>; | ||
}): AsyncIterable<ConsumerStreamResult<TData>>; | ||
@@ -62,0 +63,0 @@ export declare const sseHeaders: { |
@@ -134,2 +134,3 @@ 'use strict'; | ||
}); | ||
let errorLock = undefined; | ||
eventSource.addEventListener('message', (msg)=>{ | ||
@@ -141,3 +142,15 @@ stream.controller.enqueue(msg); | ||
}); | ||
eventSource.addEventListener('error', (cause)=>{ | ||
eventSource.addEventListener('error', async (cause)=>{ | ||
// We prevent more than 1 error handler from waiting at the same time | ||
const result = await errorLock; | ||
if (result === 'CANCEL_ALL') { | ||
return; | ||
} | ||
const resolvable = createDeferred.createDeferred(); | ||
errorLock = resolvable.promise; | ||
const handled = await opts.tryHandleError?.(cause); | ||
resolvable.resolve(); | ||
if (handled === true) { | ||
return; | ||
} | ||
if (eventSource.readyState === EventSource.CLOSED) { | ||
@@ -144,0 +157,0 @@ stream.controller.error(cause); |
{ | ||
"name": "@trpc/server", | ||
"version": "11.0.0-rc.553+9b629cc67", | ||
"version": "11.0.0-rc.560+137b085f8", | ||
"description": "The tRPC server library", | ||
@@ -152,3 +152,3 @@ "author": "KATT", | ||
], | ||
"gitHead": "9b629cc672aad7908af1d5355e3f2dd8f03f048d" | ||
"gitHead": "137b085f86cb4ceb397b29c69ccbe38a93dbe79a" | ||
} |
@@ -6,3 +6,3 @@ import { getTRPCErrorFromUnknown } from '../error/TRPCError'; | ||
import { isTrackedEnvelope } from './tracked'; | ||
import { createTimeoutPromise } from './utils/createDeferred'; | ||
import { createDeferred, createTimeoutPromise } from './utils/createDeferred'; | ||
import { createReadableStream } from './utils/createReadableStream'; | ||
@@ -193,5 +193,6 @@ | ||
export function sseStreamConsumer<TData>(opts: { | ||
from: EventSource; | ||
from: Pick<EventSource, 'addEventListener' | 'readyState'>; | ||
onError?: ConsumerOnError; | ||
deserialize?: Deserialize; | ||
tryHandleError?: (error: Event) => Promise<boolean>; | ||
}): AsyncIterable<ConsumerStreamResult<TData>> { | ||
@@ -232,2 +233,3 @@ const { deserialize = (v) => v } = opts; | ||
let errorLock: Promise<void | 'CANCEL_ALL'> | undefined = undefined; | ||
eventSource.addEventListener('message', (msg) => { | ||
@@ -239,3 +241,20 @@ stream.controller.enqueue(msg); | ||
}); | ||
eventSource.addEventListener('error', (cause) => { | ||
eventSource.addEventListener('error', async (cause) => { | ||
// We prevent more than 1 error handler from waiting at the same time | ||
const result = await errorLock; | ||
if (result === 'CANCEL_ALL') { | ||
return; | ||
} | ||
const resolvable = createDeferred<void | 'CANCEL_ALL'>(); | ||
errorLock = resolvable.promise; | ||
const handled = await opts.tryHandleError?.(cause); | ||
resolvable.resolve(); | ||
if (handled === true) { | ||
return; | ||
} | ||
if (eventSource.readyState === EventSource.CLOSED) { | ||
@@ -247,2 +266,3 @@ stream.controller.error(cause); | ||
const readable = stream.readable.pipeThrough(transform); | ||
return { | ||
@@ -249,0 +269,0 @@ [Symbol.asyncIterator]() { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
727252
18919
12