Skip to content

Commit dce7bbb

Browse files
committed
fix: 🐛 call sub-clients, prevent recursion
1 parent 67f10b6 commit dce7bbb

File tree

3 files changed

+19
-18
lines changed

3 files changed

+19
-18
lines changed

src/__tests__/e2e/json-crdt-server/clients.spec.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,19 @@ if (process.env.TEST_E2E) {
2020
}
2121
});
2222

23-
// describe('RpcPersistentClient', () => {
24-
// const {list} = setupCodecs();
25-
// for (const codec of list) {
26-
// const setup: ApiTestSetup = async () => setupFetchRpcClient(codec);
27-
// describe(`protocol: application/x.${codec.specifier()}`, () => {
28-
// runUtilTests(setup, {staticOnly: true});
29-
// runPubsubTests(setup, {staticOnly: true});
30-
// runPresenceTests(setup, {staticOnly: true});
31-
// runBlockTests(setup, {staticOnly: true});
32-
// });
33-
// }
34-
// });
23+
describe('RpcPersistentClient', () => {
24+
const {list} = setupCodecs();
25+
for (const codec of list) {
26+
const setup: ApiTestSetup = async () => setupFetchRpcClient(codec);
27+
describe(`protocol: application/x.${codec.specifier()}`, () => {
28+
runUtilTests(setup, {staticOnly: true});
29+
runPubsubTests(setup, {staticOnly: true});
30+
runPresenceTests(setup, {staticOnly: true});
31+
runBlockTests(setup, {staticOnly: true});
32+
});
33+
break;
34+
}
35+
});
3536

3637
describe('FetchRpcClient', () => {
3738
const {list} = setupCodecs();

src/common/rpc/client/EncodedStaticRpcClient.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ export class EncodedStaticRpcClient implements RpcClient {
3131
}
3232

3333
public async call(method: string, request: unknown): Promise<unknown> {
34-
return this.call(method, request);
34+
return this.client.call(method, request);
3535
}
3636

3737
public notify(method: string, data: undefined | unknown): void {
38-
this.notify(method, data);
38+
this.client.notify(method, data);
3939
}
4040
}

src/common/rpc/client/FetchRpcClient.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class FetchRpcClient implements RpcClient {
2828
const {msgCodec, reqCodec, resCodec = reqCodec, url} = options;
2929
let contentType = `application/x.rpc.${msgCodec.id}.${reqCodec.id}`;
3030
if (reqCodec.id !== resCodec.id) contentType += `-${resCodec.id}`;
31-
const myFetch = options.fetch || fetch;
31+
const currentFetch = options.fetch || fetch;
3232
this.client = new EncodedStaticRpcClient({
3333
client: new StaticRpcClient({
3434
bufferSize: options.bufferSize,
@@ -38,7 +38,7 @@ export class FetchRpcClient implements RpcClient {
3838
reqCodec,
3939
resCodec,
4040
send: async (body) => {
41-
const response = await myFetch(url, {
41+
const response = await currentFetch(url, {
4242
method: 'POST',
4343
headers: {
4444
'Content-Type': contentType,
@@ -56,11 +56,11 @@ export class FetchRpcClient implements RpcClient {
5656
}
5757

5858
public async call(method: string, request: unknown): Promise<unknown> {
59-
return this.call(method, request);
59+
return this.client.call(method, request);
6060
}
6161

6262
public notify(method: string, data: undefined | unknown): void {
63-
this.notify(method, data);
63+
this.client.notify(method, data);
6464
}
6565

6666
public stop() {}

0 commit comments

Comments
 (0)