@stream-io/video-client 1.23.0 → 1.23.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stream-io/video-client",
3
- "version": "1.23.0",
3
+ "version": "1.23.2",
4
4
  "main": "dist/index.cjs.js",
5
5
  "module": "dist/index.es.js",
6
6
  "browser": "dist/index.browser.es.js",
@@ -149,16 +149,6 @@ export class MicrophoneManager extends InputMediaDeviceManager<MicrophoneManager
149
149
  // no filter registration in React Native, its done in the native code on app init
150
150
  this.noiseCancellationRegistration = Promise.resolve();
151
151
  } else {
152
- // Krisp recommends disabling the browser's built-in noise cancellation
153
- // and echo cancellation when using Krisp, so we do that here.
154
- // https://sdk-docs.krisp.ai/docs/getting-started-js
155
- this.setDefaultConstraints({
156
- ...this.state.defaultConstraints,
157
- echoCancellation: false,
158
- noiseSuppression: false,
159
- autoGainControl: false,
160
- });
161
-
162
152
  const registrationResult = this.registerFilter(
163
153
  noiseCancellation.toFilter(),
164
154
  );
@@ -6,6 +6,8 @@ import {
6
6
  withRequestTracer,
7
7
  } from '../createClient';
8
8
  import { TwirpFetchTransport } from '@protobuf-ts/twirp-transport';
9
+ import { NextUnaryFn, UnaryCall } from '@protobuf-ts/runtime-rpc';
10
+ import { promiseWithResolvers } from '../../helpers/promise';
9
11
 
10
12
  describe('createClient', () => {
11
13
  it('should create a client with TwirpFetchTransport', () => {
@@ -28,9 +30,8 @@ describe('createClient', () => {
28
30
 
29
31
  it('withRequestLogger should log the request', () => {
30
32
  const logger = vi.fn();
31
- const level = 'debug';
32
- const interceptor = withRequestLogger(logger, level);
33
- const next = vi.fn();
33
+ const interceptor = withRequestLogger(logger, 'debug');
34
+ const next = vi.fn().mockReturnValue({});
34
35
  // @ts-expect-error - private field
35
36
  interceptor.interceptUnary(next, { name: 'test' }, null, null);
36
37
  expect(next).toHaveBeenCalled();
@@ -40,7 +41,8 @@ describe('createClient', () => {
40
41
  it('withRequestTracer should add trace to the request', () => {
41
42
  const trace = vi.fn();
42
43
  const interceptor = withRequestTracer(trace);
43
- const next = vi.fn();
44
+ // @ts-expect-error - partial implementation
45
+ const next: NextUnaryFn = vi.fn(() => ({ then: () => Promise.resolve() }));
44
46
  interceptor.interceptUnary(
45
47
  next,
46
48
  // @ts-expect-error - invalid name
@@ -52,25 +54,32 @@ describe('createClient', () => {
52
54
  expect(trace).toHaveBeenCalledWith('TestMethod', { param: 'value' });
53
55
  });
54
56
 
55
- it('withRequestTracer should add an error trace', () => {
57
+ it('withRequestTracer should add a failure trace when the SFU returns an error', async () => {
56
58
  const trace = vi.fn();
57
59
  const interceptor = withRequestTracer(trace);
58
- const err = new Error('test error');
59
- const next = vi.fn(() => {
60
- throw err;
61
- });
62
- expect(() =>
63
- interceptor.interceptUnary(
64
- next,
65
- // @ts-expect-error - invalid name
66
- { name: 'TestMethod' },
67
- { param: 'value' },
68
- { meta: {} },
69
- ),
70
- ).toThrow('test error');
71
- expect(trace).toHaveBeenLastCalledWith('TestMethodOnFailure', [
60
+ const { promise, resolve } = promiseWithResolvers<UnaryCall['then']>();
61
+ // @ts-expect-error - partial implementation
62
+ const next = vi.fn<NextUnaryFn>(() => ({
63
+ // @ts-expect-error - incompatible type
64
+ then: (...args) => promise.then(...args),
65
+ }));
66
+ interceptor.interceptUnary(
67
+ next,
68
+ // @ts-expect-error - invalid name
69
+ { name: 'TestMethod' },
70
+ { param: 'value' },
71
+ { meta: {} },
72
+ );
73
+ expect(next).toHaveBeenCalled();
74
+
75
+ // @ts-expect-error - partial data
76
+ resolve({ response: { error: { msg: 'err' } } });
77
+ await promise;
78
+
79
+ expect(trace).toHaveBeenCalledWith('TestMethod', { param: 'value' });
80
+ expect(trace).toHaveBeenCalledWith('TestMethodOnFailure', [
81
+ { msg: 'err' },
72
82
  { param: 'value' },
73
- err,
74
83
  ]);
75
84
  });
76
85
  });
@@ -12,6 +12,7 @@ import {
12
12
  import { SignalServerClient } from '../gen/video/sfu/signal_rpc/signal.client';
13
13
  import { Logger, LogLevel } from '../coordinator/connection/types';
14
14
  import type { Trace } from '../stats';
15
+ import type { SfuResponseWithError } from './retryable';
15
16
 
16
17
  const defaultOptions: TwirpOptions = {
17
18
  baseUrl: '',
@@ -49,16 +50,13 @@ export const withRequestLogger = (
49
50
  input: object,
50
51
  options: RpcOptions,
51
52
  ): UnaryCall => {
52
- let invocation: UnaryCall | undefined;
53
- try {
54
- invocation = next(method, input, options);
55
- } finally {
56
- logger(level, `Invoked SFU RPC method ${method.name}`, {
57
- request: invocation?.request,
58
- headers: invocation?.requestHeaders,
59
- response: invocation?.response,
60
- });
61
- }
53
+ const invocation = next(method, input, options);
54
+ logger(level, `Invoked SFU RPC method ${method.name}`, {
55
+ request: invocation.request,
56
+ headers: invocation.requestHeaders,
57
+ response: invocation.response,
58
+ });
59
+
62
60
  return invocation;
63
61
  },
64
62
  };
@@ -69,6 +67,9 @@ export const withRequestTracer = (trace: Trace): RpcInterceptor => {
69
67
  [K in keyof SignalServerClient as Capitalize<K>]: boolean;
70
68
  };
71
69
 
70
+ const traceError = (name: string, input: object, err: unknown) =>
71
+ trace(`${name}OnFailure`, [err, input]);
72
+
72
73
  const exclusions: Record<string, boolean | undefined> = {
73
74
  SendStats: true,
74
75
  } satisfies Partial<RpcMethodNames>;
@@ -82,13 +83,17 @@ export const withRequestTracer = (trace: Trace): RpcInterceptor => {
82
83
  if (exclusions[method.name as keyof RpcMethodNames]) {
83
84
  return next(method, input, options);
84
85
  }
85
- try {
86
- trace(method.name, input);
87
- return next(method, input, options);
88
- } catch (err) {
89
- trace(`${method.name}OnFailure`, [input, err]);
90
- throw err;
91
- }
86
+
87
+ trace(method.name, input);
88
+ const unaryCall = next(method, input, options);
89
+ unaryCall.then(
90
+ (invocation) => {
91
+ const err = (invocation.response as SfuResponseWithError)?.error;
92
+ if (err) traceError(method.name, input, err);
93
+ },
94
+ (err) => traceError(method.name, input, err),
95
+ );
96
+ return unaryCall;
92
97
  },
93
98
  };
94
99
  };