trpc-uwebsockets 10.44.0 → 10.45.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -65,10 +65,8 @@ const app = App();
65
65
 
66
66
  /* handle CORS as needed */
67
67
  app.options('/*', (res) => {
68
- res.cork(() => {
69
- res.writeHeader('Access-Control-Allow-Origin', allowOrigin);
70
- res.endWithoutBody();
71
- });
68
+ res.writeHeader('Access-Control-Allow-Origin', allowOrigin);
69
+ res.endWithoutBody();
72
70
  });
73
71
 
74
72
  createUWebSocketsHandler(app, '/trpc', {
package/dist/utils.js CHANGED
@@ -24,7 +24,7 @@ function getPostBody(method, res, maxBodySize) {
24
24
  return;
25
25
  }
26
26
  const chunk = Buffer.from(ab);
27
- if (maxBodySize && buffer.length >= maxBodySize) {
27
+ if (maxBodySize && buffer && buffer.length >= maxBodySize) {
28
28
  resolve({
29
29
  ok: false,
30
30
  error: new server_1.TRPCError({ code: 'PAYLOAD_TOO_LARGE' }),
package/dist/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AAEA,yCAAyC;AAGzC,SAAgB,WAAW,CAAC,MAAM,EAAE,GAAiB,EAAE,WAAoB;IACzE,OAAO,IAAI,OAAO,CAGhB,CAAC,OAAO,EAAE,EAAE;QACZ,IAAI,MAAM,IAAI,KAAK,EAAE;YACnB,yBAAyB;YACzB,OAAO,CAAC;gBACN,EAAE,EAAE,IAAI;gBACR,IAAI,EAAE,SAAS;gBACf,YAAY,EAAE,KAAK;aACpB,CAAC,CAAC;SACJ;QAED,IAAI,MAAc,CAAC;QAEnB,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE;YACxB,+CAA+C;YAC/C,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,EAAE;gBAClC,OAAO,CAAC;oBACN,EAAE,EAAE,IAAI;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AAC;IAEH,OAAO;QACL,OAAO;QACP,MAAM;QACN,KAAK;QACL,GAAG;KACJ,CAAC;AACJ,CAAC;AAnBD,8DAmBC"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "private": false,
3
3
  "name": "trpc-uwebsockets",
4
4
  "description": "tRPC adapter for uWebSockets.js server",
5
- "version": "10.44.0",
5
+ "version": "10.45.0",
6
6
  "main": "./dist/index.js",
7
7
  "type": "commonjs",
8
8
  "types": "./types/index.d.ts",
package/src/utils.ts CHANGED
@@ -3,7 +3,11 @@ import { HttpRequest, HttpResponse } from 'uWebSockets.js';
3
3
  import { TRPCError } from '@trpc/server';
4
4
  import { WrappedHTTPRequest } from './types';
5
5
 
6
- export function getPostBody(method, res: HttpResponse, maxBodySize?: number) {
6
+ export function getPostBody(
7
+ method: 'GET' | 'POST',
8
+ res: HttpResponse,
9
+ maxBodySize?: number
10
+ ) {
7
11
  return new Promise<
8
12
  | { ok: true; data: unknown; preprocessed: boolean }
9
13
  | { ok: false; error: TRPCError }
@@ -17,7 +21,7 @@ export function getPostBody(method, res: HttpResponse, maxBodySize?: number) {
17
21
  });
18
22
  }
19
23
 
20
- let buffer: Buffer;
24
+ let buffer: Buffer | undefined;
21
25
 
22
26
  res.onData((ab, isLast) => {
23
27
  //resolve right away if there is only one chunk
@@ -32,7 +36,7 @@ export function getPostBody(method, res: HttpResponse, maxBodySize?: number) {
32
36
 
33
37
  const chunk = Buffer.from(ab);
34
38
 
35
- if (maxBodySize && buffer.length >= maxBodySize) {
39
+ if (maxBodySize && buffer && buffer.length >= maxBodySize) {
36
40
  resolve({
37
41
  ok: false,
38
42
  error: new TRPCError({ code: 'PAYLOAD_TOO_LARGE' }),
@@ -1,12 +1,4 @@
1
- import {
2
- vi,
3
- beforeEach,
4
- afterEach,
5
- test,
6
- expect,
7
- expectTypeOf,
8
- describe,
9
- } from 'vitest';
1
+ import { vi, beforeEach, afterEach, test, expect, expectTypeOf } from 'vitest';
10
2
  // idk how to use that
11
3
  // import { waitFor } from '@testing-library/dom';
12
4
 
@@ -153,6 +145,7 @@ async function startServer() {
153
145
  },
154
146
  };
155
147
  },
148
+ maxBodySize: 10000,
156
149
 
157
150
  router,
158
151
  createContext: makeContext(),
@@ -302,37 +295,34 @@ const linkSpy: TRPCLink<AppRouter> = () => {
302
295
  };
303
296
  };
304
297
 
305
- describe('main tests', () => {
306
- test('query simple success and error handling', async () => {
307
- // t.client.runtime.headers = ()
308
- const { client } = makeClient({});
309
-
310
- // client.
311
- expect(
312
- await client.hello.query({
313
- who: 'test',
314
- })
315
- ).toMatchInlineSnapshot(`
298
+ test('query simple success and error handling', async () => {
299
+ // t.client.runtime.headers = ()
300
+ const { client } = makeClient({});
301
+
302
+ // client.
303
+ expect(
304
+ await client.hello.query({
305
+ who: 'test',
306
+ })
307
+ ).toMatchInlineSnapshot(`
316
308
  {
317
309
  "text": "hello test",
318
310
  }
319
311
  `);
320
312
 
321
- await expect(client.error.query()).rejects.toThrowError(
322
- 'error as expected'
323
- );
324
- });
313
+ await expect(client.error.query()).rejects.toThrowError('error as expected');
314
+ });
325
315
 
326
- test('mutation and reading headers', async () => {
327
- const { client } = makeClient({
328
- authorization: 'meow',
329
- });
316
+ test('mutation and reading headers', async () => {
317
+ const { client } = makeClient({
318
+ authorization: 'meow',
319
+ });
330
320
 
331
- expect(
332
- await client.test.mutate({
333
- value: 'lala',
334
- })
335
- ).toMatchInlineSnapshot(`
321
+ expect(
322
+ await client.test.mutate({
323
+ value: 'lala',
324
+ })
325
+ ).toMatchInlineSnapshot(`
336
326
  {
337
327
  "originalValue": "lala",
338
328
  "user": {
@@ -340,99 +330,99 @@ describe('main tests', () => {
340
330
  },
341
331
  }
342
332
  `);
343
- });
344
-
345
- test('manually sets status and headers', async () => {
346
- const fetcher = await fetch(
347
- `http://localhost:${testPort}/trpc/manualRes?input=${encodeURI('{}')}`
348
- );
349
- const body = await fetcher.json();
350
- expect(fetcher.status).toEqual(400);
351
- expect(body.result.data).toEqual('status 400');
333
+ });
352
334
 
353
- expect(fetcher.headers.get('Access-Control-Allow-Origin')).toEqual('*'); // from the meta
354
- expect(fetcher.headers.get('manual')).toEqual('header'); //from the result
355
- });
335
+ test('manually sets status and headers', async () => {
336
+ const fetcher = await fetch(
337
+ `http://localhost:${testPort}/trpc/manualRes?input=${encodeURI('{}')}`
338
+ );
339
+ const body = await fetcher.json();
340
+ expect(fetcher.status).toEqual(400);
341
+ expect(body.result.data).toEqual('status 400');
356
342
 
357
- // this needs to be tested
358
- test('aborting requests works', async () => {
359
- const ac = new AbortController();
360
- const { client } = makeClient({});
343
+ expect(fetcher.headers.get('Access-Control-Allow-Origin')).toEqual('*'); // from the meta
344
+ expect(fetcher.headers.get('manual')).toEqual('header'); //from the result
345
+ });
361
346
 
362
- expect.assertions(1);
347
+ // this needs to be tested
348
+ test('aborting requests works', async () => {
349
+ const ac = new AbortController();
350
+ const { client } = makeClient({});
363
351
 
364
- setTimeout(() => {
365
- ac.abort();
366
- });
352
+ expect.assertions(1);
367
353
 
368
- try {
369
- await client.test.mutate(
370
- {
371
- value: 'haha',
372
- },
373
- {
374
- signal: ac.signal as any,
375
- }
376
- );
377
- } catch (error) {
378
- expect(error.name).toBe('TRPCClientError');
379
- }
354
+ setTimeout(() => {
355
+ ac.abort();
380
356
  });
381
357
 
382
- // FIXME no idea how to make it non-flaky
383
- const sleep = (ms: number) => new Promise((res) => setTimeout(res, ms));
384
-
385
- // Source: https://github.com/trpc/trpc/blob/main/packages/tests/server/adapters/fastify.test.ts
386
- test(
387
- 'ugly subscription tests',
388
- async () => {
389
- ee.once('subscription:created', () => {
390
- setTimeout(() => {
391
- ee.emit('server:msg', {
392
- id: '1',
393
- });
394
- ee.emit('server:msg', {
395
- id: '2',
396
- });
358
+ try {
359
+ await client.test.mutate(
360
+ {
361
+ value: 'haha',
362
+ },
363
+ {
364
+ signal: ac.signal as any,
365
+ }
366
+ );
367
+ } catch (error) {
368
+ expect(error.name).toBe('TRPCClientError');
369
+ }
370
+ });
371
+
372
+ // FIXME no idea how to make it non-flaky
373
+ const sleep = (ms: number) => new Promise((res) => setTimeout(res, ms));
374
+
375
+ // Source: https://github.com/trpc/trpc/blob/main/packages/tests/server/adapters/fastify.test.ts
376
+ test(
377
+ 'ugly subscription tests',
378
+ async () => {
379
+ ee.once('subscription:created', () => {
380
+ setTimeout(() => {
381
+ ee.emit('server:msg', {
382
+ id: '1',
383
+ });
384
+ ee.emit('server:msg', {
385
+ id: '2',
397
386
  });
398
387
  });
388
+ });
399
389
 
400
- const { client, closeWs } = makeClientWithWs({});
390
+ const { client, closeWs } = makeClientWithWs({});
401
391
 
402
- const onStartedMock = vi.fn();
403
- const onDataMock = vi.fn();
404
- const sub = client.onMessage.subscribe('onMessage', {
405
- onStarted: onStartedMock,
406
- onData(data) {
407
- expectTypeOf(data).not.toBeAny();
408
- expectTypeOf(data).toMatchTypeOf<Message>();
409
- onDataMock(data);
410
- },
411
- });
392
+ const onStartedMock = vi.fn();
393
+ const onDataMock = vi.fn();
394
+ const sub = client.onMessage.subscribe('onMessage', {
395
+ onStarted: onStartedMock,
396
+ onData(data) {
397
+ expectTypeOf(data).not.toBeAny();
398
+ expectTypeOf(data).toMatchTypeOf<Message>();
399
+ onDataMock(data);
400
+ },
401
+ });
412
402
 
413
- // onStartedMock.
403
+ // onStartedMock.
414
404
 
415
- // expect(onStartedMock).toh
405
+ // expect(onStartedMock).toh
416
406
 
417
- await sleep(300); // FIXME how to use waitFor instead?
418
- expect(onStartedMock).toHaveBeenCalledTimes(1);
419
- expect(onDataMock).toHaveBeenCalledTimes(2);
420
- // await waitFor(() => {
421
- // expect(onStartedMock).toHaveBeenCalledTimes(1);
422
- // expect(onDataMock).toHaveBeenCalledTimes(2);
423
- // });
407
+ await sleep(300); // FIXME how to use waitFor instead?
408
+ expect(onStartedMock).toHaveBeenCalledTimes(1);
409
+ expect(onDataMock).toHaveBeenCalledTimes(2);
410
+ // await waitFor(() => {
411
+ // expect(onStartedMock).toHaveBeenCalledTimes(1);
412
+ // expect(onDataMock).toHaveBeenCalledTimes(2);
413
+ // });
424
414
 
425
- ee.emit('server:msg', {
426
- id: '3',
427
- });
428
- await sleep(500);
429
- expect(onDataMock).toHaveBeenCalledTimes(3);
415
+ ee.emit('server:msg', {
416
+ id: '3',
417
+ });
418
+ await sleep(500);
419
+ expect(onDataMock).toHaveBeenCalledTimes(3);
430
420
 
431
- // await waitFor(() => {
432
- // expect(onDataMock).toHaveBeenCalledTimes(3);
433
- // });
421
+ // await waitFor(() => {
422
+ // expect(onDataMock).toHaveBeenCalledTimes(3);
423
+ // });
434
424
 
435
- expect(onDataMock.mock.calls).toMatchInlineSnapshot(`
425
+ expect(onDataMock.mock.calls).toMatchInlineSnapshot(`
436
426
  [
437
427
  [
438
428
  {
@@ -452,64 +442,77 @@ describe('main tests', () => {
452
442
  ]
453
443
  `);
454
444
 
455
- sub.unsubscribe();
445
+ sub.unsubscribe();
446
+
447
+ await sleep(500);
448
+
449
+ expect(ee.listenerCount('server:msg')).toBe(0);
450
+ expect(ee.listenerCount('server:error')).toBe(0);
451
+
452
+ await closeWs();
453
+ },
454
+ {
455
+ timeout: 10000,
456
+ }
457
+ );
458
+
459
+ test(
460
+ 'subscription failed context',
461
+ async () => {
462
+ expect.assertions(2);
463
+ // const host = `localhost:${testPort}/trpc?user=user1`; // weClient can inject values via query string
464
+ const host = `localhost:${testPort}/trpc?user=user1&fail=yess`; // weClient can inject values via query string
465
+ const wsClient = createWSClient({
466
+ url: `ws://${host}`,
467
+ WebSocket,
468
+ retryDelayMs: (i) => {
469
+ console.log('retrying connection in subscription only', i);
470
+ return 200;
471
+ },
472
+ });
456
473
 
457
- await sleep(500);
474
+ const client = createTRPCProxyClient<AppRouter>({
475
+ links: [wsLink({ client: wsClient })],
476
+ });
458
477
 
459
- expect(ee.listenerCount('server:msg')).toBe(0);
460
- expect(ee.listenerCount('server:error')).toBe(0);
478
+ client.onMessage.subscribe('lala', {
479
+ onError(err) {
480
+ // expect this error here?
481
+ expect(err).toBeInstanceOf(TRPCClientError);
482
+ expect(err.message).toBe('failing as expected');
483
+ },
484
+ });
461
485
 
462
- await closeWs();
463
- },
486
+ await sleep(100);
487
+ wsClient.close();
488
+ },
489
+ {
490
+ timeout: 3000,
491
+ }
492
+ );
493
+
494
+ test('options still passthrough (cors)', async () => {
495
+ const res = await fetch(
496
+ `http://localhost:${testPort}/trpc/hello?input=${encodeURI('{}')}`,
464
497
  {
465
- timeout: 10000,
498
+ method: 'OPTIONS',
466
499
  }
467
500
  );
468
501
 
469
- test(
470
- 'subscription failed context',
471
- async () => {
472
- expect.assertions(2);
473
- // const host = `localhost:${testPort}/trpc?user=user1`; // weClient can inject values via query string
474
- const host = `localhost:${testPort}/trpc?user=user1&fail=yess`; // weClient can inject values via query string
475
- const wsClient = createWSClient({
476
- url: `ws://${host}`,
477
- WebSocket,
478
- retryDelayMs: (i) => {
479
- console.log('retrying connection in subscription only', i);
480
- return 200;
481
- },
482
- });
483
-
484
- const client = createTRPCProxyClient<AppRouter>({
485
- links: [wsLink({ client: wsClient })],
486
- });
487
-
488
- client.onMessage.subscribe('lala', {
489
- onError(err) {
490
- // expect this error here?
491
- expect(err).toBeInstanceOf(TRPCClientError);
492
- expect(err.message).toBe('failing as expected');
493
- },
494
- });
495
-
496
- await sleep(100);
497
- wsClient.close();
498
- },
499
- {
500
- timeout: 3000,
501
- }
502
- );
502
+ expect(res.status).toBe(200);
503
+ expect(res.headers.get('Access-Control-Allow-Origin')).toBe('*');
504
+ });
503
505
 
504
- test('options still passthrough (cors)', async () => {
505
- const res = await fetch(
506
- `http://localhost:${testPort}/trpc/hello?input=${encodeURI('{}')}`,
507
- {
508
- method: 'OPTIONS',
509
- }
510
- );
506
+ test('large request body handling', async () => {
507
+ const { client } = makeClient({});
508
+ expect.assertions(2);
511
509
 
512
- expect(res.status).toBe(200);
513
- expect(res.headers.get('Access-Control-Allow-Origin')).toBe('*');
514
- });
510
+ try {
511
+ await client.test.mutate({
512
+ value: '0'.repeat(200000),
513
+ });
514
+ } catch (error) {
515
+ expect(error.name).toBe('TRPCClientError');
516
+ expect(error.data.code).toBe('PAYLOAD_TOO_LARGE');
517
+ }
515
518
  });
package/types/utils.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { HttpRequest, HttpResponse } from 'uWebSockets.js';
2
2
  import { TRPCError } from '@trpc/server';
3
3
  import { WrappedHTTPRequest } from './types';
4
- export declare function getPostBody(method: any, res: HttpResponse, maxBodySize?: number): Promise<{
4
+ export declare function getPostBody(method: 'GET' | 'POST', res: HttpResponse, maxBodySize?: number): Promise<{
5
5
  ok: true;
6
6
  data: unknown;
7
7
  preprocessed: boolean;