diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 1011f9e6..3d1d8a55 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -15,7 +15,7 @@ module.exports = { sourceType: 'module', project: ['./tsconfig.json'], }, - plugins: ['@typescript-eslint'], + plugins: ['@typescript-eslint', '@stylistic/js', '@stylistic/ts'], rules: { 'linebreak-style': ['error', 'unix'], '@typescript-eslint/no-confusing-void-expression': [ @@ -44,6 +44,21 @@ module.exports = { allowNumber: true, }, ], + '@stylistic/ts/lines-between-class-members': [ + 'error', + 'always', + { exceptAfterSingleLine: true }, + ], + '@stylistic/js/no-multiple-empty-lines': ['error', { max: 1 }], + '@stylistic/ts/padding-line-between-statements': [ + 'error', + { blankLine: 'always', prev: '*', next: 'return' }, + { + blankLine: 'always', + prev: '*', + next: ['enum', 'interface', 'type'], + }, + ], }, ignorePatterns: ['dist/**/*'], }; diff --git a/__tests__/bandwidth.bench.ts b/__tests__/bandwidth.bench.ts index 529c8faa..87e2e15d 100644 --- a/__tests__/bandwidth.bench.ts +++ b/__tests__/bandwidth.bench.ts @@ -41,6 +41,7 @@ describe('bandwidth', async () => { const msg = dummyPayloadSmall(); const id = sendClosure(msg); await waitForMessage(serverTransport, (msg) => msg.id === id); + return; }, { time: BENCH_DURATION }, diff --git a/__tests__/cancellation.test.ts b/__tests__/cancellation.test.ts index fe15bdae..5dd79ccb 100644 --- a/__tests__/cancellation.test.ts +++ b/__tests__/cancellation.test.ts @@ -51,6 +51,7 @@ describe.each(testMatrix(['ws', 'naive']))( const setup = await transport.setup({ client: opts, server: opts }); getClientTransport = setup.getClientTransport; getServerTransport = setup.getServerTransport; + return async () => { await postTestCleanup(); await setup.cleanup(); @@ -336,6 +337,7 @@ describe.each(testMatrix())( const setup = await transport.setup({ client: opts, server: opts }); getClientTransport = setup.getClientTransport; getServerTransport = setup.getServerTransport; + return async () => { await postTestCleanup(); await setup.cleanup(); @@ -591,6 +593,7 @@ describe.each(testMatrix())( const setup = await transport.setup({ client: opts, server: opts }); getClientTransport = setup.getClientTransport; getServerTransport = setup.getServerTransport; + return async () => { await postTestCleanup(); await setup.cleanup(); diff --git a/__tests__/cleanup.test.ts b/__tests__/cleanup.test.ts index adac5986..fb77b0e0 100644 --- a/__tests__/cleanup.test.ts +++ b/__tests__/cleanup.test.ts @@ -45,6 +45,7 @@ describe.each(testMatrix())( const setup = await transport.setup({ client: opts, server: opts }); getClientTransport = setup.getClientTransport; getServerTransport = setup.getServerTransport; + return async () => { await postTestCleanup(); await setup.cleanup(); @@ -487,6 +488,7 @@ describe('request finishing triggers signal onabort', async () => { const setup = await transport.setup({ client: opts, server: opts }); getClientTransport = setup.getClientTransport; getServerTransport = setup.getServerTransport; + return async () => { await postTestCleanup(); await setup.cleanup(); diff --git a/__tests__/context.test.ts b/__tests__/context.test.ts index 45ea9d11..0c5e1b52 100644 --- a/__tests__/context.test.ts +++ b/__tests__/context.test.ts @@ -26,6 +26,7 @@ describe('should handle incompatabilities', async () => { }); getClientTransport = setup.getClientTransport; getServerTransport = setup.getServerTransport; + return async () => { await postTestCleanup(); await setup.cleanup(); diff --git a/__tests__/disconnects.test.ts b/__tests__/disconnects.test.ts index 56e25e42..fef6b1f7 100644 --- a/__tests__/disconnects.test.ts +++ b/__tests__/disconnects.test.ts @@ -37,6 +37,7 @@ describe.each(testMatrix())( const setup = await transport.setup({ client: opts, server: opts }); getClientTransport = setup.getClientTransport; getServerTransport = setup.getServerTransport; + return async () => { await postTestCleanup(); await setup.cleanup(); diff --git a/__tests__/e2e.test.ts b/__tests__/e2e.test.ts index 6adafe77..02b79ff8 100644 --- a/__tests__/e2e.test.ts +++ b/__tests__/e2e.test.ts @@ -52,6 +52,7 @@ describe.each(testMatrix())( const setup = await transport.setup({ client: opts, server: opts }); getClientTransport = setup.getClientTransport; getServerTransport = setup.getServerTransport; + return async () => { await postTestCleanup(); await setup.cleanup(); diff --git a/__tests__/fixtures/cleanup.ts b/__tests__/fixtures/cleanup.ts index 7eac34d6..60a63b56 100644 --- a/__tests__/fixtures/cleanup.ts +++ b/__tests__/fixtures/cleanup.ts @@ -160,6 +160,7 @@ export async function testFinishesCleanly({ export const createPostTestCleanups = () => { const cleanupFns: Array<() => Promise> = []; + return { addPostTestCleanup: (fn: () => Promise) => { cleanupFns.push(fn); diff --git a/__tests__/fixtures/observable.ts b/__tests__/fixtures/observable.ts index a5784fd6..75db8fb1 100644 --- a/__tests__/fixtures/observable.ts +++ b/__tests__/fixtures/observable.ts @@ -37,6 +37,7 @@ export class Observable { observe(listener: (val: T) => void) { this.listeners.add(listener); listener(this.get()); + return () => this.listeners.delete(listener); } diff --git a/__tests__/fixtures/services.ts b/__tests__/fixtures/services.ts index d0ed7d67..17098c30 100644 --- a/__tests__/fixtures/services.ts +++ b/__tests__/fixtures/services.ts @@ -20,6 +20,7 @@ const testServiceProcedures = TestServiceScaffold.procedures({ responseData: Type.Object({ result: Type.Number() }), async handler({ ctx, reqInit: { n } }) { ctx.state.count += n; + return Ok({ result: ctx.state.count }); }, }), @@ -29,6 +30,7 @@ const testServiceProcedures = TestServiceScaffold.procedures({ responseData: Type.Array(Type.Number()), async handler({ ctx, reqInit: { n } }) { ctx.state.count += n; + return Ok([ctx.state.count]); }, }), @@ -133,6 +135,7 @@ export const OrderingServiceSchema = ServiceSchema.define( responseData: Type.Object({ n: Type.Number() }), async handler({ ctx, reqInit: { n } }) { ctx.state.msgs.push(n); + return Ok({ n }); }, }), @@ -153,6 +156,7 @@ export const BinaryFileServiceSchema = ServiceSchema.define({ responseData: Type.Object({ contents: Type.Uint8Array() }), async handler({ reqInit: { file } }) { const bytes: Uint8Array = Buffer.from(`contents for file ${file}`); + return Ok({ contents: bytes }); }, }), @@ -236,6 +240,7 @@ export const SubscribableServiceSchema = ServiceSchema.define( responseData: Type.Object({ result: Type.Number() }), async handler({ ctx, reqInit: { n } }) { ctx.state.count.set((prev) => prev + n); + return Ok({ result: ctx.state.count.get() }); }, }), @@ -278,6 +283,7 @@ export const UploadableServiceSchema = ServiceSchema.define({ for await (const req of reqReadable) { result += unwrapOrThrow(req).n; } + return Ok({ result: `${reqInit.prefix} ${result}` }); }, }), diff --git a/__tests__/fixtures/transports.ts b/__tests__/fixtures/transports.ts index 76bebab4..7c8c6deb 100644 --- a/__tests__/fixtures/transports.ts +++ b/__tests__/fixtures/transports.ts @@ -58,6 +58,7 @@ export const transports: Array = [ const transports: Array< WebSocketClientTransport | WebSocketServerTransport > = []; + return { simulatePhantomDisconnect() { for (const transport of transports) { @@ -87,6 +88,7 @@ export const transports: Array = [ }, 'debug'); transports.push(clientTransport); + return clientTransport; }, getServerTransport(handshakeOptions) { @@ -110,6 +112,7 @@ export const transports: Array = [ } transports.push(serverTransport); + return serverTransport as ServerTransport; }, async restartServer() { diff --git a/__tests__/invalid-request.test.ts b/__tests__/invalid-request.test.ts index 25e66445..40384bc4 100644 --- a/__tests__/invalid-request.test.ts +++ b/__tests__/invalid-request.test.ts @@ -33,6 +33,7 @@ describe('cancels invalid request', () => { const setup = await transport.setup({ client: opts, server: opts }); getClientTransport = setup.getClientTransport; getServerTransport = setup.getServerTransport; + return async () => { await postTestCleanup(); await setup.cleanup(); diff --git a/__tests__/negative.test.ts b/__tests__/negative.test.ts index 53f9bf15..b8cea88c 100644 --- a/__tests__/negative.test.ts +++ b/__tests__/negative.test.ts @@ -110,6 +110,7 @@ describe('should handle incompatabilities', async () => { const clientTransport = new WebSocketClientTransport( () => { connectCalls++; + return Promise.resolve(createLocalWebSocketClient(port)); }, 'client', diff --git a/codec/json.ts b/codec/json.ts index 225fad2d..78973989 100644 --- a/codec/json.ts +++ b/codec/json.ts @@ -9,6 +9,7 @@ function uint8ArrayToBase64(uint8Array: Uint8Array) { uint8Array.forEach((byte) => { binary += String.fromCharCode(byte); }); + return btoa(binary); } @@ -19,6 +20,7 @@ function base64ToUint8Array(base64: string) { for (let i = 0; i < binaryString.length; i++) { uint8Array[i] = binaryString.charCodeAt(i); } + return uint8Array; } @@ -59,6 +61,7 @@ export const NaiveJsonCodec: Codec = { ) as unknown; if (typeof parsed === 'object') return parsed; + return null; } catch { return null; diff --git a/logging/log.ts b/logging/log.ts index 73b5e88d..b2f5f8d3 100644 --- a/logging/log.ts +++ b/logging/log.ts @@ -29,6 +29,7 @@ const cleanedLogFn = (log: LogFn) => { // skip cloning object if metadata has no transportMessage if (!metadata?.transportMessage) { log(msg, metadata); + return; } diff --git a/package-lock.json b/package-lock.json index a0905df2..82044be5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,6 +17,8 @@ "@opentelemetry/core": "^1.7.0", "@opentelemetry/sdk-trace-base": "^1.24.1", "@opentelemetry/sdk-trace-web": "^1.24.1", + "@stylistic/eslint-plugin": "^2.6.4", + "@stylistic/eslint-plugin-ts": "^2.6.4", "@types/ws": "^8.5.5", "@typescript-eslint/eslint-plugin": "^7.8.0", "@typescript-eslint/parser": "^7.8.0", @@ -922,12 +924,305 @@ "integrity": "sha512-ifqNG6GBr0QRao2Vy+2P2WzxkOnpGmHfZCFXWwuR/0elH4h79mGXN8mEYwnJ2qGEr7MGgfqvf8Njwj4dBGFMBA==", "peer": true }, + "node_modules/@stylistic/eslint-plugin": { + "version": "2.6.4", + "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin/-/eslint-plugin-2.6.4.tgz", + "integrity": "sha512-euUGnjzH8EOqEYTGk9dB2OBINp0FX1nuO7/k4fO82zNRBIKZgJoDwTLM4Ce+Om6W1Qmh1PrZjCr4jh4tMEXGPQ==", + "dev": true, + "dependencies": { + "@stylistic/eslint-plugin-js": "2.6.4", + "@stylistic/eslint-plugin-jsx": "2.6.4", + "@stylistic/eslint-plugin-plus": "2.6.4", + "@stylistic/eslint-plugin-ts": "2.6.4", + "@types/eslint": "^9.6.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "peerDependencies": { + "eslint": ">=8.40.0" + } + }, + "node_modules/@stylistic/eslint-plugin-js": { + "version": "2.6.4", + "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin-js/-/eslint-plugin-js-2.6.4.tgz", + "integrity": "sha512-kx1hS3xTvzxZLdr/DCU/dLBE++vcP97sHeEFX2QXhk1Ipa4K1rzPOLw1HCbf4mU3s+7kHP5eYpDe+QteEOFLug==", + "dev": true, + "dependencies": { + "@types/eslint": "^9.6.0", + "acorn": "^8.12.1", + "eslint-visitor-keys": "^4.0.0", + "espree": "^10.1.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "peerDependencies": { + "eslint": ">=8.40.0" + } + }, + "node_modules/@stylistic/eslint-plugin-js/node_modules/eslint-visitor-keys": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.0.0.tgz", + "integrity": "sha512-OtIRv/2GyiF6o/d8K7MYKKbXrOUBIK6SfkIRM4Z0dY3w+LiQ0vy3F57m0Z71bjbyeiWFiHJ8brqnmE6H6/jEuw==", + "dev": true, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@stylistic/eslint-plugin-js/node_modules/espree": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-10.1.0.tgz", + "integrity": "sha512-M1M6CpiE6ffoigIOWYO9UDP8TMUw9kqb21tf+08IgDYjCsOvCuDt4jQcZmoYxx+w7zlKw9/N0KXfto+I8/FrXA==", + "dev": true, + "dependencies": { + "acorn": "^8.12.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^4.0.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@stylistic/eslint-plugin-jsx": { + "version": "2.6.4", + "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin-jsx/-/eslint-plugin-jsx-2.6.4.tgz", + "integrity": "sha512-bIvVhdtjmyu3S10V7QRIuawtCZSq9gRmzAX23ucjCOdSFzEwlq+di0IM0riBAvvQerrJL4SM6G3xgyPs8BSXIA==", + "dev": true, + "dependencies": { + "@stylistic/eslint-plugin-js": "^2.6.4", + "@types/eslint": "^9.6.0", + "eslint-visitor-keys": "^4.0.0", + "espree": "^10.1.0", + "estraverse": "^5.3.0", + "picomatch": "^4.0.2" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "peerDependencies": { + "eslint": ">=8.40.0" + } + }, + "node_modules/@stylistic/eslint-plugin-jsx/node_modules/eslint-visitor-keys": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.0.0.tgz", + "integrity": "sha512-OtIRv/2GyiF6o/d8K7MYKKbXrOUBIK6SfkIRM4Z0dY3w+LiQ0vy3F57m0Z71bjbyeiWFiHJ8brqnmE6H6/jEuw==", + "dev": true, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@stylistic/eslint-plugin-jsx/node_modules/espree": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-10.1.0.tgz", + "integrity": "sha512-M1M6CpiE6ffoigIOWYO9UDP8TMUw9kqb21tf+08IgDYjCsOvCuDt4jQcZmoYxx+w7zlKw9/N0KXfto+I8/FrXA==", + "dev": true, + "dependencies": { + "acorn": "^8.12.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^4.0.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@stylistic/eslint-plugin-jsx/node_modules/picomatch": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.2.tgz", + "integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/@stylistic/eslint-plugin-plus": { + "version": "2.6.4", + "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin-plus/-/eslint-plugin-plus-2.6.4.tgz", + "integrity": "sha512-EuRvtxhf7Hv8OoMIePulP/6rBJIgPTu1l5GAm1780WcF1Cl8bOZXIn84Pdac5pNv6lVlzCOFm8MD3VE+2YROuA==", + "dev": true, + "dependencies": { + "@types/eslint": "^9.6.0" + }, + "peerDependencies": { + "eslint": "*" + } + }, + "node_modules/@stylistic/eslint-plugin-ts": { + "version": "2.6.4", + "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin-ts/-/eslint-plugin-ts-2.6.4.tgz", + "integrity": "sha512-yxL8Hj6WkObw1jfiLpBzKy5yfxY6vwlwO4miq34ySErUjUecPV5jxfVbOe4q1QDPKemQGPq93v7sAQS5PzM8lA==", + "dev": true, + "dependencies": { + "@stylistic/eslint-plugin-js": "2.6.4", + "@types/eslint": "^9.6.0", + "@typescript-eslint/utils": "^8.1.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "peerDependencies": { + "eslint": ">=8.40.0" + } + }, + "node_modules/@stylistic/eslint-plugin-ts/node_modules/@typescript-eslint/scope-manager": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.2.0.tgz", + "integrity": "sha512-OFn80B38yD6WwpoHU2Tz/fTz7CgFqInllBoC3WP+/jLbTb4gGPTy9HBSTsbDWkMdN55XlVU0mMDYAtgvlUspGw==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "8.2.0", + "@typescript-eslint/visitor-keys": "8.2.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@stylistic/eslint-plugin-ts/node_modules/@typescript-eslint/types": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.2.0.tgz", + "integrity": "sha512-6a9QSK396YqmiBKPkJtxsgZZZVjYQ6wQ/TlI0C65z7vInaETuC6HAHD98AGLC8DyIPqHytvNuS8bBVvNLKyqvQ==", + "dev": true, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@stylistic/eslint-plugin-ts/node_modules/@typescript-eslint/typescript-estree": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.2.0.tgz", + "integrity": "sha512-kiG4EDUT4dImplOsbh47B1QnNmXSoUqOjWDvCJw/o8LgfD0yr7k2uy54D5Wm0j4t71Ge1NkynGhpWdS0dEIAUA==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "8.2.0", + "@typescript-eslint/visitor-keys": "8.2.0", + "debug": "^4.3.4", + "globby": "^11.1.0", + "is-glob": "^4.0.3", + "minimatch": "^9.0.4", + "semver": "^7.6.0", + "ts-api-utils": "^1.3.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@stylistic/eslint-plugin-ts/node_modules/@typescript-eslint/utils": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.2.0.tgz", + "integrity": "sha512-O46eaYKDlV3TvAVDNcoDzd5N550ckSe8G4phko++OCSC1dYIb9LTc3HDGYdWqWIAT5qDUKphO6sd9RrpIJJPfg==", + "dev": true, + "dependencies": { + "@eslint-community/eslint-utils": "^4.4.0", + "@typescript-eslint/scope-manager": "8.2.0", + "@typescript-eslint/types": "8.2.0", + "@typescript-eslint/typescript-estree": "8.2.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0" + } + }, + "node_modules/@stylistic/eslint-plugin-ts/node_modules/@typescript-eslint/visitor-keys": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.2.0.tgz", + "integrity": "sha512-sbgsPMW9yLvS7IhCi8IpuK1oBmtbWUNP+hBdwl/I9nzqVsszGnNGti5r9dUtF5RLivHUFFIdRvLiTsPhzSyJ3Q==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "8.2.0", + "eslint-visitor-keys": "^3.4.3" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@stylistic/eslint-plugin-ts/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/@stylistic/eslint-plugin-ts/node_modules/minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@types/eslint": { + "version": "9.6.0", + "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-9.6.0.tgz", + "integrity": "sha512-gi6WQJ7cHRgZxtkQEoyHMppPjq9Kxo5Tjn2prSKDSmZrCz8TZ3jSRCeTJm+WoM+oB0WG37bRqLzaaU3q7JypGg==", + "dev": true, + "dependencies": { + "@types/estree": "*", + "@types/json-schema": "*" + } + }, "node_modules/@types/estree": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==", "dev": true }, + "node_modules/@types/json-schema": { + "version": "7.0.15", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", + "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", + "dev": true + }, "node_modules/@types/node": { "version": "20.5.7", "resolved": "https://registry.npmjs.org/@types/node/-/node-20.5.7.tgz", @@ -1261,9 +1556,9 @@ } }, "node_modules/acorn": { - "version": "8.11.3", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz", - "integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==", + "version": "8.12.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.1.tgz", + "integrity": "sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg==", "dev": true, "bin": { "acorn": "bin/acorn" @@ -4591,12 +4886,205 @@ "integrity": "sha512-ifqNG6GBr0QRao2Vy+2P2WzxkOnpGmHfZCFXWwuR/0elH4h79mGXN8mEYwnJ2qGEr7MGgfqvf8Njwj4dBGFMBA==", "peer": true }, + "@stylistic/eslint-plugin": { + "version": "2.6.4", + "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin/-/eslint-plugin-2.6.4.tgz", + "integrity": "sha512-euUGnjzH8EOqEYTGk9dB2OBINp0FX1nuO7/k4fO82zNRBIKZgJoDwTLM4Ce+Om6W1Qmh1PrZjCr4jh4tMEXGPQ==", + "dev": true, + "requires": { + "@stylistic/eslint-plugin-js": "2.6.4", + "@stylistic/eslint-plugin-jsx": "2.6.4", + "@stylistic/eslint-plugin-plus": "2.6.4", + "@stylistic/eslint-plugin-ts": "2.6.4", + "@types/eslint": "^9.6.0" + } + }, + "@stylistic/eslint-plugin-js": { + "version": "2.6.4", + "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin-js/-/eslint-plugin-js-2.6.4.tgz", + "integrity": "sha512-kx1hS3xTvzxZLdr/DCU/dLBE++vcP97sHeEFX2QXhk1Ipa4K1rzPOLw1HCbf4mU3s+7kHP5eYpDe+QteEOFLug==", + "dev": true, + "requires": { + "@types/eslint": "^9.6.0", + "acorn": "^8.12.1", + "eslint-visitor-keys": "^4.0.0", + "espree": "^10.1.0" + }, + "dependencies": { + "eslint-visitor-keys": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.0.0.tgz", + "integrity": "sha512-OtIRv/2GyiF6o/d8K7MYKKbXrOUBIK6SfkIRM4Z0dY3w+LiQ0vy3F57m0Z71bjbyeiWFiHJ8brqnmE6H6/jEuw==", + "dev": true + }, + "espree": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-10.1.0.tgz", + "integrity": "sha512-M1M6CpiE6ffoigIOWYO9UDP8TMUw9kqb21tf+08IgDYjCsOvCuDt4jQcZmoYxx+w7zlKw9/N0KXfto+I8/FrXA==", + "dev": true, + "requires": { + "acorn": "^8.12.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^4.0.0" + } + } + } + }, + "@stylistic/eslint-plugin-jsx": { + "version": "2.6.4", + "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin-jsx/-/eslint-plugin-jsx-2.6.4.tgz", + "integrity": "sha512-bIvVhdtjmyu3S10V7QRIuawtCZSq9gRmzAX23ucjCOdSFzEwlq+di0IM0riBAvvQerrJL4SM6G3xgyPs8BSXIA==", + "dev": true, + "requires": { + "@stylistic/eslint-plugin-js": "^2.6.4", + "@types/eslint": "^9.6.0", + "eslint-visitor-keys": "^4.0.0", + "espree": "^10.1.0", + "estraverse": "^5.3.0", + "picomatch": "^4.0.2" + }, + "dependencies": { + "eslint-visitor-keys": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.0.0.tgz", + "integrity": "sha512-OtIRv/2GyiF6o/d8K7MYKKbXrOUBIK6SfkIRM4Z0dY3w+LiQ0vy3F57m0Z71bjbyeiWFiHJ8brqnmE6H6/jEuw==", + "dev": true + }, + "espree": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-10.1.0.tgz", + "integrity": "sha512-M1M6CpiE6ffoigIOWYO9UDP8TMUw9kqb21tf+08IgDYjCsOvCuDt4jQcZmoYxx+w7zlKw9/N0KXfto+I8/FrXA==", + "dev": true, + "requires": { + "acorn": "^8.12.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^4.0.0" + } + }, + "picomatch": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.2.tgz", + "integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==", + "dev": true + } + } + }, + "@stylistic/eslint-plugin-plus": { + "version": "2.6.4", + "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin-plus/-/eslint-plugin-plus-2.6.4.tgz", + "integrity": "sha512-EuRvtxhf7Hv8OoMIePulP/6rBJIgPTu1l5GAm1780WcF1Cl8bOZXIn84Pdac5pNv6lVlzCOFm8MD3VE+2YROuA==", + "dev": true, + "requires": { + "@types/eslint": "^9.6.0" + } + }, + "@stylistic/eslint-plugin-ts": { + "version": "2.6.4", + "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin-ts/-/eslint-plugin-ts-2.6.4.tgz", + "integrity": "sha512-yxL8Hj6WkObw1jfiLpBzKy5yfxY6vwlwO4miq34ySErUjUecPV5jxfVbOe4q1QDPKemQGPq93v7sAQS5PzM8lA==", + "dev": true, + "requires": { + "@stylistic/eslint-plugin-js": "2.6.4", + "@types/eslint": "^9.6.0", + "@typescript-eslint/utils": "^8.1.0" + }, + "dependencies": { + "@typescript-eslint/scope-manager": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.2.0.tgz", + "integrity": "sha512-OFn80B38yD6WwpoHU2Tz/fTz7CgFqInllBoC3WP+/jLbTb4gGPTy9HBSTsbDWkMdN55XlVU0mMDYAtgvlUspGw==", + "dev": true, + "requires": { + "@typescript-eslint/types": "8.2.0", + "@typescript-eslint/visitor-keys": "8.2.0" + } + }, + "@typescript-eslint/types": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.2.0.tgz", + "integrity": "sha512-6a9QSK396YqmiBKPkJtxsgZZZVjYQ6wQ/TlI0C65z7vInaETuC6HAHD98AGLC8DyIPqHytvNuS8bBVvNLKyqvQ==", + "dev": true + }, + "@typescript-eslint/typescript-estree": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.2.0.tgz", + "integrity": "sha512-kiG4EDUT4dImplOsbh47B1QnNmXSoUqOjWDvCJw/o8LgfD0yr7k2uy54D5Wm0j4t71Ge1NkynGhpWdS0dEIAUA==", + "dev": true, + "requires": { + "@typescript-eslint/types": "8.2.0", + "@typescript-eslint/visitor-keys": "8.2.0", + "debug": "^4.3.4", + "globby": "^11.1.0", + "is-glob": "^4.0.3", + "minimatch": "^9.0.4", + "semver": "^7.6.0", + "ts-api-utils": "^1.3.0" + } + }, + "@typescript-eslint/utils": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.2.0.tgz", + "integrity": "sha512-O46eaYKDlV3TvAVDNcoDzd5N550ckSe8G4phko++OCSC1dYIb9LTc3HDGYdWqWIAT5qDUKphO6sd9RrpIJJPfg==", + "dev": true, + "requires": { + "@eslint-community/eslint-utils": "^4.4.0", + "@typescript-eslint/scope-manager": "8.2.0", + "@typescript-eslint/types": "8.2.0", + "@typescript-eslint/typescript-estree": "8.2.0" + } + }, + "@typescript-eslint/visitor-keys": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.2.0.tgz", + "integrity": "sha512-sbgsPMW9yLvS7IhCi8IpuK1oBmtbWUNP+hBdwl/I9nzqVsszGnNGti5r9dUtF5RLivHUFFIdRvLiTsPhzSyJ3Q==", + "dev": true, + "requires": { + "@typescript-eslint/types": "8.2.0", + "eslint-visitor-keys": "^3.4.3" + } + }, + "brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0" + } + }, + "minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "requires": { + "brace-expansion": "^2.0.1" + } + } + } + }, + "@types/eslint": { + "version": "9.6.0", + "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-9.6.0.tgz", + "integrity": "sha512-gi6WQJ7cHRgZxtkQEoyHMppPjq9Kxo5Tjn2prSKDSmZrCz8TZ3jSRCeTJm+WoM+oB0WG37bRqLzaaU3q7JypGg==", + "dev": true, + "requires": { + "@types/estree": "*", + "@types/json-schema": "*" + } + }, "@types/estree": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==", "dev": true }, + "@types/json-schema": { + "version": "7.0.15", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", + "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", + "dev": true + }, "@types/node": { "version": "20.5.7", "resolved": "https://registry.npmjs.org/@types/node/-/node-20.5.7.tgz", @@ -4813,9 +5301,9 @@ } }, "acorn": { - "version": "8.11.3", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz", - "integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==", + "version": "8.12.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.1.tgz", + "integrity": "sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg==", "dev": true }, "acorn-jsx": { diff --git a/package.json b/package.json index 923e574e..630fdf8a 100644 --- a/package.json +++ b/package.json @@ -60,6 +60,7 @@ "@opentelemetry/core": "^1.7.0", "@opentelemetry/sdk-trace-base": "^1.24.1", "@opentelemetry/sdk-trace-web": "^1.24.1", + "@stylistic/eslint-plugin": "^2.6.4", "@types/ws": "^8.5.5", "@typescript-eslint/eslint-plugin": "^7.8.0", "@typescript-eslint/parser": "^7.8.0", diff --git a/router/client.ts b/router/client.ts index 0ac6754b..0f19c443 100644 --- a/router/client.ts +++ b/router/client.ts @@ -167,6 +167,7 @@ function _createRecursiveProxy( // property access, recurse and add field to path get(_obj, key) { if (typeof key !== 'string') return undefined; + return _createRecursiveProxy(callback, [...path, key]); }, // hit the end, let's invoke the handler @@ -506,6 +507,7 @@ function handleProc( if (procType === 'upload') { let didFinalize = false; + return { reqWritable: reqWritable, finalize: () => { diff --git a/router/errors.ts b/router/errors.ts index 90f1e8e7..8c90f922 100644 --- a/router/errors.ts +++ b/router/errors.ts @@ -80,6 +80,7 @@ export type ProcedureErrorSchemaType = type NestableProcedureErrorSchemaType = | BaseErrorSchemaType | TUnion; + // use an interface to defer the type definition to be evaluated lazily // eslint-disable-next-line @typescript-eslint/no-empty-interface interface NestableProcedureErrorSchemaTypeArray @@ -127,5 +128,6 @@ export function flattenErrorType( } flatten(errType); + return Type.Union(flattenedTypes); } diff --git a/router/server.ts b/router/server.ts index 341f1a63..66ab69c6 100644 --- a/router/server.ts +++ b/router/server.ts @@ -178,6 +178,7 @@ class RiverServer const stream = this.streams.get(streamId); if (stream) { stream.handleMsg(message); + return; } diff --git a/router/services.ts b/router/services.ts index 3e48e981..509f76ac 100644 --- a/router/services.ts +++ b/router/services.ts @@ -164,6 +164,7 @@ export function serializeSchemaV1Compat( Record >((acc, [name, value]) => { acc[name] = value.serializeV1Compat(); + return acc; }, {}); @@ -206,6 +207,7 @@ export function serializeSchema( Record >((acc, [name, value]) => { acc[name] = value.serialize(); + return acc; }, {}); diff --git a/router/streams.ts b/router/streams.ts index 3eac1e39..abefb4b4 100644 --- a/router/streams.ts +++ b/router/streams.ts @@ -103,6 +103,7 @@ export interface Writable { */ isWritable(): boolean; } + /** * @internal * @@ -248,6 +249,7 @@ export class ReadableImpl> }, return: () => { this.break(); + return { done: true, value: undefined } as const; }, }; diff --git a/tracing/index.ts b/tracing/index.ts index f20f8b08..c51afa6e 100644 --- a/tracing/index.ts +++ b/tracing/index.ts @@ -28,6 +28,7 @@ export function getPropagationContext( tracestate: '', }; propagation.inject(ctx, tracing); + return tracing; } @@ -117,6 +118,7 @@ export function createProcTelemetryInfo( spanId: span.spanContext().spanId, }, }); + return { span, ctx }; } diff --git a/tracing/tracing.test.ts b/tracing/tracing.test.ts index 1fb165b8..4f276b55 100644 --- a/tracing/tracing.test.ts +++ b/tracing/tracing.test.ts @@ -94,6 +94,7 @@ describe.each(testMatrix())( const setup = await transport.setup({ client: opts, server: opts }); getClientTransport = setup.getClientTransport; getServerTransport = setup.getServerTransport; + return async () => { await postTestCleanup(); await setup.cleanup(); diff --git a/transport/client.ts b/transport/client.ts index 52fe5fc3..448682fd 100644 --- a/transport/client.ts +++ b/transport/client.ts @@ -114,6 +114,7 @@ export abstract class ClientTransport< ); this.createSession(session); + return session; } @@ -121,6 +122,7 @@ export abstract class ClientTransport< protected onConnectingFailed(session: SessionConnecting) { const noConnectionSession = super.onConnectingFailed(session); this.tryReconnecting(noConnectionSession.to); + return noConnectionSession; } @@ -129,6 +131,7 @@ export abstract class ClientTransport< ) { const noConnectionSession = super.onConnClosed(session); this.tryReconnecting(noConnectionSession.to); + return noConnectionSession; } @@ -187,6 +190,7 @@ export abstract class ClientTransport< this.updateSession(handshakingSession); void this.sendHandshake(handshakingSession); + return handshakingSession; } @@ -218,6 +222,7 @@ export abstract class ClientTransport< ...Value.Errors(ControlMessageHandshakeResponseSchema, msg.payload), ], }); + return; } @@ -255,6 +260,7 @@ export abstract class ClientTransport< ...session.loggingMetadata, transportMessage: msg, }); + return; } @@ -306,6 +312,7 @@ export abstract class ClientTransport< this.log?.info( `transport state is no longer open, cancelling attempt to connect to ${to}`, ); + return; } @@ -316,6 +323,7 @@ export abstract class ClientTransport< `session to ${to} has state ${session.state}, skipping connect attempt`, session.loggingMetadata, ); + return; } @@ -328,6 +336,7 @@ export abstract class ClientTransport< type: ProtocolError.RetriesExceeded, message: errMsg, }); + return; } diff --git a/transport/impls/ws/client.ts b/transport/impls/ws/client.ts index 710e1706..dea22b13 100644 --- a/transport/impls/ws/client.ts +++ b/transport/impls/ws/client.ts @@ -42,11 +42,13 @@ export class WebSocketClientTransport extends ClientTransport((resolve, reject) => { if (ws.readyState === ws.OPEN) { resolve(); + return; } if (ws.readyState === ws.CLOSING || ws.readyState === ws.CLOSED) { reject(new Error('ws is closing or closed')); + return; } diff --git a/transport/impls/ws/connection.ts b/transport/impls/ws/connection.ts index f76118db..6a82149a 100644 --- a/transport/impls/ws/connection.ts +++ b/transport/impls/ws/connection.ts @@ -63,6 +63,7 @@ export class WebSocketConnection extends Connection { } this.ws.send(payload); + return true; } diff --git a/transport/impls/ws/ws.test.ts b/transport/impls/ws/ws.test.ts index 0df16698..e791656d 100644 --- a/transport/impls/ws/ws.test.ts +++ b/transport/impls/ws/ws.test.ts @@ -91,6 +91,7 @@ describe('sending and receiving across websockets works', async () => { await expect( waitForMessage(serverTransport, (recv) => recv.id === initMsgId), ).resolves.toStrictEqual(initMsg.payload); + return client; }; diff --git a/transport/rateLimit.ts b/transport/rateLimit.ts index b0f7031f..04768a03 100644 --- a/transport/rateLimit.ts +++ b/transport/rateLimit.ts @@ -94,6 +94,7 @@ export class LeakyBucketRateLimit { const currentBudget = this.budgetConsumed; if (!currentBudget) { this.stopLeak(); + return; } diff --git a/transport/server.ts b/transport/server.ts index 419061a1..f9f46260 100644 --- a/transport/server.ts +++ b/transport/server.ts @@ -140,6 +140,7 @@ export abstract class ServerTransport< ); this.deletePendingSession(pendingSession); + return; } @@ -432,6 +433,7 @@ export abstract class ServerTransport< transportMessage: msg, }, ); + return; } diff --git a/transport/sessionStateMachine/SessionConnected.ts b/transport/sessionStateMachine/SessionConnected.ts index bbbfa983..0de225f1 100644 --- a/transport/sessionStateMachine/SessionConnected.ts +++ b/transport/sessionStateMachine/SessionConnected.ts @@ -52,6 +52,7 @@ export class SessionConnected< const constructedMsg = this.constructMsg(msg); this.sendBuffer.push(constructedMsg); this.conn.send(this.options.codec.toBuffer(constructedMsg)); + return constructedMsg.id; } @@ -103,6 +104,7 @@ export class SessionConnected< this.conn.close(); clearInterval(this.heartbeatHandle); this.heartbeatHandle = undefined; + return; } @@ -147,6 +149,7 @@ export class SessionConnected< const parsedMsg = this.parseMsg(msg); if (parsedMsg === null) { this.listeners.onInvalidMessage('could not parse message'); + return; } @@ -192,6 +195,7 @@ export class SessionConnected< // dispatch directly if its not an explicit ack if (!isAck(parsedMsg.controlFlags)) { this.listeners.onMessage(parsedMsg); + return; } diff --git a/transport/sessionStateMachine/SessionHandshaking.ts b/transport/sessionStateMachine/SessionHandshaking.ts index 9cc7e907..3fe2e099 100644 --- a/transport/sessionStateMachine/SessionHandshaking.ts +++ b/transport/sessionStateMachine/SessionHandshaking.ts @@ -73,6 +73,7 @@ export class SessionHandshaking< 'could not parse message', 'MALFORMED_HANDSHAKE', ); + return; } diff --git a/transport/sessionStateMachine/SessionWaitingForHandshake.ts b/transport/sessionStateMachine/SessionWaitingForHandshake.ts index d3ca2051..851f372c 100644 --- a/transport/sessionStateMachine/SessionWaitingForHandshake.ts +++ b/transport/sessionStateMachine/SessionWaitingForHandshake.ts @@ -68,6 +68,7 @@ export class SessionWaitingForHandshake< 'could not parse message', 'MALFORMED_HANDSHAKE', ); + return; } diff --git a/transport/sessionStateMachine/common.ts b/transport/sessionStateMachine/common.ts index ef08a20c..32f7e549 100644 --- a/transport/sessionStateMachine/common.ts +++ b/transport/sessionStateMachine/common.ts @@ -165,6 +165,7 @@ export abstract class CommonSession extends StateMachineState { `received malformed msg: ${decodedBuffer}`, this.loggingMetadata, ); + return null; } @@ -264,6 +265,7 @@ export abstract class IdentifiedSession extends CommonSession { }; this.seq++; + return msg; } @@ -274,6 +276,7 @@ export abstract class IdentifiedSession extends CommonSession { send(msg: PartialTransportMessage): string { const constructedMsg = this.constructMsg(msg); this.sendBuffer.push(constructedMsg); + return constructedMsg.id; } diff --git a/transport/sessionStateMachine/stateMachine.test.ts b/transport/sessionStateMachine/stateMachine.test.ts index 76567d27..dcb2aefe 100644 --- a/transport/sessionStateMachine/stateMachine.test.ts +++ b/transport/sessionStateMachine/stateMachine.test.ts @@ -80,6 +80,7 @@ interface PendingMockConnectionHandle { function getPendingMockConnection(): PendingMockConnectionHandle { let resolve: (conn: MockConnection) => void; let reject: (err: Error) => void; + return { pendingConn: new Promise((res, rej) => { resolve = res; diff --git a/transport/sessionStateMachine/transitions.ts b/transport/sessionStateMachine/transitions.ts index 47c9cf4b..925f347c 100644 --- a/transport/sessionStateMachine/transitions.ts +++ b/transport/sessionStateMachine/transitions.ts @@ -146,6 +146,7 @@ export const SessionStateGraph = { tags: ['state-transition'], }, ); + return session; }, BackingOffToConnecting: ( @@ -169,6 +170,7 @@ export const SessionStateGraph = { tags: ['state-transition'], }, ); + return session; }, ConnectingToHandshaking: ( diff --git a/transport/transforms/messageFraming.ts b/transport/transforms/messageFraming.ts index 1338a712..93decf2e 100644 --- a/transport/transforms/messageFraming.ts +++ b/transport/transforms/messageFraming.ts @@ -30,6 +30,7 @@ export class Uint32LengthPrefixFraming extends Transform { this.emit('error', err); cb(err); + return; } @@ -76,6 +77,7 @@ export const MessageFramer = { write: (buf: Uint8Array) => { const lengthPrefix = Buffer.alloc(4); lengthPrefix.writeUInt32BE(buf.length, 0); + return Buffer.concat([lengthPrefix, buf]); }, }; diff --git a/transport/transport.test.ts b/transport/transport.test.ts index 01477146..8201d2cd 100644 --- a/transport/transport.test.ts +++ b/transport/transport.test.ts @@ -44,6 +44,7 @@ describe.each(testMatrix())( const setup = await transport.setup({ client: opts, server: opts }); getClientTransport = setup.getClientTransport; getServerTransport = setup.getServerTransport; + return async () => { await postTestCleanup(); await setup.cleanup(); @@ -556,6 +557,7 @@ describe.each(testMatrix())( await expect( waitForMessage(serverTransport, (recv) => recv.id === initMsgId), ).resolves.toStrictEqual(initMsg.payload); + return client; }; @@ -608,6 +610,7 @@ describe.each(testMatrix())( testHelpers = await transport.setup({ client: opts, server: opts }); getClientTransport = testHelpers.getClientTransport; getServerTransport = testHelpers.getServerTransport; + return async () => { await postTestCleanup(); await testHelpers.cleanup(); @@ -681,6 +684,7 @@ describe.each(testMatrix())( testHelpers = await transport.setup({ client: clientOpts, server: opts }); getClientTransport = testHelpers.getClientTransport; getServerTransport = testHelpers.getServerTransport; + return async () => { await postTestCleanup(); await testHelpers.cleanup(); @@ -760,6 +764,7 @@ describe.each(testMatrix())( const { addPostTestCleanup, postTestCleanup } = createPostTestCleanups(); beforeEach(async () => { testHelpers = await transport.setup({ client: opts, server: opts }); + return async () => { await postTestCleanup(); await testHelpers.cleanup(); @@ -834,6 +839,7 @@ describe.each(testMatrix())( await new Promise((resolve) => setTimeout(resolve, testingClientSessionOptions.handshakeTimeoutMs), ); + return {}; }, }); @@ -1235,6 +1241,7 @@ describe.each(testMatrix())( const setup = await transport.setup({ client: opts, server: opts }); getClientTransport = setup.getClientTransport; getServerTransport = setup.getServerTransport; + return async () => { await postTestCleanup(); await setup.cleanup(); diff --git a/transport/transport.ts b/transport/transport.ts index b024c9f6..548db290 100644 --- a/transport/transport.ts +++ b/transport/transport.ts @@ -107,6 +107,7 @@ export abstract class Transport { // construct logger from fn if (typeof fn === 'function') { this.log = createLogProxy(new BaseLogger(fn, level)); + return; } @@ -272,6 +273,7 @@ export abstract class Transport { }); this.updateSession(noConnectionSession); + return noConnectionSession; } @@ -297,6 +299,7 @@ export abstract class Transport { } this.updateSession(noConnectionSession); + return noConnectionSession; } diff --git a/util/testHelpers.ts b/util/testHelpers.ts index 94bea1d6..70d57e52 100644 --- a/util/testHelpers.ts +++ b/util/testHelpers.ts @@ -187,6 +187,7 @@ export async function waitForMessage( function catchProcError(err: unknown) { const errorMsg = coerceErrorString(err); + return Err({ code: UNCAUGHT_ERROR_CODE, message: errorMsg }); }