Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@trpc/client

Package Overview
Dependencies
Maintainers
0
Versions
1066
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@trpc/client - npm Package Compare versions

Comparing version 11.0.0-rc.524 to 11.0.0-rc.528

44

dist/bundle-analysis.json
{
"bundleSize": 52661,
"bundleOrigSize": 70097,
"bundleReduction": 24.87,
"bundleSize": 52387,
"bundleOrigSize": 69892,
"bundleReduction": 25.05,
"modules": [
{
"id": "/src/links/wsLink.ts",
"size": 13710,
"origSize": 15265,
"size": 13436,
"origSize": 15060,
"renderedExports": [

@@ -16,4 +16,4 @@ "createWSClient",

"dependents": [],
"percent": 26.03,
"reduction": 10.19
"percent": 25.65,
"reduction": 10.78
},

@@ -29,3 +29,3 @@ {

"dependents": [],
"percent": 11.13,
"percent": 11.19,
"reduction": 3.51

@@ -42,3 +42,3 @@ },

"dependents": [],
"percent": 10.36,
"percent": 10.42,
"reduction": 18.48

@@ -62,8 +62,8 @@ },

"dependents": [
"/src/links/httpLink.ts",
"/src/links/httpBatchLink.ts",
"/src/links/httpLink.ts",
"/src/links/httpBatchStreamLink.ts",
"/src/links/httpSubscriptionLink.ts"
],
"percent": 8.48,
"percent": 8.52,
"reduction": 32.82

@@ -83,3 +83,3 @@ },

],
"percent": 7.76,
"percent": 7.8,
"reduction": 5.64

@@ -96,3 +96,3 @@ },

"dependents": [],
"percent": 7.45,
"percent": 7.49,
"reduction": 4.69

@@ -109,3 +109,3 @@ },

"dependents": [],
"percent": 7.23,
"percent": 7.26,
"reduction": 9.86

@@ -122,3 +122,3 @@ },

"dependents": [],
"percent": 6.05,
"percent": 6.08,
"reduction": 14.15

@@ -138,3 +138,3 @@ },

],
"percent": 4.11,
"percent": 4.13,
"reduction": 47.6

@@ -152,4 +152,4 @@ },

"/src/index.ts",
"/src/links/httpLink.ts",
"/src/links/httpBatchLink.ts",
"/src/links/httpLink.ts",
"/src/links/wsLink.ts",

@@ -160,3 +160,3 @@ "/src/links/httpBatchStreamLink.ts",

],
"percent": 3.68,
"percent": 3.7,
"reduction": 45.43

@@ -178,3 +178,3 @@ },

],
"percent": 2.25,
"percent": 2.27,
"reduction": 73.19

@@ -194,3 +194,3 @@ },

],
"percent": 1.31,
"percent": 1.32,
"reduction": 32.75

@@ -221,3 +221,3 @@ },

],
"percent": 1.07,
"percent": 1.08,
"reduction": 66.75

@@ -237,3 +237,3 @@ },

],
"percent": 0.81,
"percent": 0.82,
"reduction": 33.54

@@ -240,0 +240,0 @@ },

@@ -62,7 +62,6 @@ 'use strict';

}
function tryReconnect(conn) {
function tryReconnect() {
if (!!connectTimer) {
return;
}
conn.state = 'connecting';
const timeout = retryDelayFn(connectAttempt++);

@@ -130,7 +129,28 @@ reconnectInMs(timeout);

clearTimeout(lazyDisconnectTimer);
const onError = (evt)=>{
const onCloseOrError = ()=>{
if (self.state === 'closed') {
return;
}
self.state = 'closed';
if (self === activeConnection) {
tryReconnect(self);
if (activeConnection === self) {
// connection might have been replaced already
tryReconnect();
}
for (const [key, req] of Object.entries(pendingRequests)){
if (req.connection !== self) {
continue;
}
// The connection was closed either unexpectedly or because of a reconnect
if (req.type === 'subscription') {
// Subscriptions will resume after we've reconnected
resumeSubscriptionOnReconnect(req);
} else {
// Queries and mutations will error if interrupted
delete pendingRequests[key];
req.callbacks.error?.(TRPCClientError.TRPCClientError.from(new TRPCWebSocketClosedError('WebSocket closed prematurely')));
}
}
};
const onError = (evt)=>{
onCloseOrError();
opts.onError?.(evt);

@@ -194,7 +214,9 @@ };

if (self === activeConnection && req.connection !== activeConnection) {
// gracefully replace old connection with this
const oldConn = req.connection;
// gracefully replace old connection with a new connection
req.connection = self;
oldConn && closeIfNoPending(oldConn);
}
if (req.connection !== self) {
// the connection has been replaced
return;
}
if ('result' in data && data.result.type === 'data' && typeof data.result.id === 'string') {

@@ -221,3 +243,5 @@ req.lastEventId = data.result.id;

ws.addEventListener('close', ({ code })=>{
if (self.state === 'open') {
const wasOpen = self.state === 'open';
onCloseOrError();
if (wasOpen) {
opts.onClose?.({

@@ -227,27 +251,2 @@ code

}
self.state = 'closed';
if (activeConnection === self) {
// connection might have been replaced already
tryReconnect(self);
}
for (const [key, req] of Object.entries(pendingRequests)){
if (req.connection !== self) {
continue;
}
if (self.state === 'closed') {
// If the connection was closed, we just call `complete()` on the request
delete pendingRequests[key];
req.callbacks.complete?.();
continue;
}
// The connection was closed either unexpectedly or because of a reconnect
if (req.type === 'subscription') {
// Subscriptions will resume after we've reconnected
resumeSubscriptionOnReconnect(req);
} else {
// Queries and mutations will error if interrupted
delete pendingRequests[key];
req.callbacks.error?.(TRPCClientError.TRPCClientError.from(new TRPCWebSocketClosedError('WebSocket closed prematurely')));
}
}
});

@@ -254,0 +253,0 @@ }).catch(onError);

{
"name": "@trpc/client",
"version": "11.0.0-rc.524+df45b1a7c",
"version": "11.0.0-rc.528+32e6b1285",
"description": "The tRPC client library",

@@ -79,6 +79,6 @@ "author": "KATT",

"peerDependencies": {
"@trpc/server": "11.0.0-rc.524+df45b1a7c"
"@trpc/server": "11.0.0-rc.528+32e6b1285"
},
"devDependencies": {
"@trpc/server": "11.0.0-rc.524+df45b1a7c",
"@trpc/server": "11.0.0-rc.528+32e6b1285",
"@types/isomorphic-fetch": "^0.0.39",

@@ -100,3 +100,3 @@ "@types/node": "^20.10.0",

],
"gitHead": "df45b1a7c13a3f5c47373a0d2b38c68f5c6c1028"
"gitHead": "32e6b1285dd844776d323ae23fbea638312d676e"
}

@@ -180,8 +180,6 @@ import type { Observer, UnsubscribeFn } from '@trpc/server/observable';

}
function tryReconnect(conn: Connection) {
function tryReconnect() {
if (!!connectTimer) {
return;
}
conn.state = 'connecting';
const timeout = retryDelayFn(connectAttempt++);

@@ -257,7 +255,36 @@ reconnectInMs(timeout);

const onCloseOrError = () => {
if (self.state === 'closed') {
return;
}
(self as Connection).state = 'closed';
if (activeConnection === self) {
// connection might have been replaced already
tryReconnect();
}
for (const [key, req] of Object.entries(pendingRequests)) {
if (req.connection !== self) {
continue;
}
// The connection was closed either unexpectedly or because of a reconnect
if (req.type === 'subscription') {
// Subscriptions will resume after we've reconnected
resumeSubscriptionOnReconnect(req);
} else {
// Queries and mutations will error if interrupted
delete pendingRequests[key];
req.callbacks.error?.(
TRPCClientError.from(
new TRPCWebSocketClosedError('WebSocket closed prematurely'),
),
);
}
}
};
const onError = (evt?: Event) => {
self.state = 'closed';
if (self === activeConnection) {
tryReconnect(self);
}
onCloseOrError();
opts.onError?.(evt);

@@ -333,7 +360,9 @@ };

if (self === activeConnection && req.connection !== activeConnection) {
// gracefully replace old connection with this
const oldConn = req.connection;
// gracefully replace old connection with a new connection
req.connection = self;
oldConn && closeIfNoPending(oldConn);
}
if (req.connection !== self) {
// the connection has been replaced
return;
}

@@ -372,37 +401,8 @@ if (

ws.addEventListener('close', ({ code }) => {
if (self.state === 'open') {
const wasOpen = self.state === 'open';
onCloseOrError();
if (wasOpen) {
opts.onClose?.({ code });
}
self.state = 'closed';
if (activeConnection === self) {
// connection might have been replaced already
tryReconnect(self);
}
for (const [key, req] of Object.entries(pendingRequests)) {
if (req.connection !== self) {
continue;
}
if (self.state === 'closed') {
// If the connection was closed, we just call `complete()` on the request
delete pendingRequests[key];
req.callbacks.complete?.();
continue;
}
// The connection was closed either unexpectedly or because of a reconnect
if (req.type === 'subscription') {
// Subscriptions will resume after we've reconnected
resumeSubscriptionOnReconnect(req);
} else {
// Queries and mutations will error if interrupted
delete pendingRequests[key];
req.callbacks.error?.(
TRPCClientError.from(
new TRPCWebSocketClosedError('WebSocket closed prematurely'),
),
);
}
}
});

@@ -409,0 +409,0 @@ }).catch(onError);

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc