@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/CHANGELOG.md +12 -0
- package/dist/index.browser.es.js +17 -30
- package/dist/index.browser.es.js.map +1 -1
- package/dist/index.cjs.js +17 -30
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +17 -30
- package/dist/index.es.js.map +1 -1
- package/package.json +1 -1
- package/src/devices/MicrophoneManager.ts +0 -10
- package/src/rpc/__tests__/createClient.test.ts +29 -20
- package/src/rpc/createClient.ts +22 -17
package/package.json
CHANGED
|
@@ -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
|
|
32
|
-
const
|
|
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
|
-
|
|
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
|
|
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
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
)
|
|
71
|
-
expect(
|
|
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
|
});
|
package/src/rpc/createClient.ts
CHANGED
|
@@ -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
|
-
|
|
53
|
-
|
|
54
|
-
invocation
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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
|
};
|