fix: broken backwards compatibity
This commit is contained in:
Родитель
d5525d3a25
Коммит
216f30e73b
|
@ -102,6 +102,29 @@ describe('RPC', () => {
|
|||
},
|
||||
}));
|
||||
|
||||
it('does not break on an empty/errorful ready reply (back compat)', () =>
|
||||
testMarbles({
|
||||
rpcInstance: 'a--de',
|
||||
remoteContx: '-bc--',
|
||||
definitions: {
|
||||
a: { action: Action.IsReady, value: false },
|
||||
b: expectReady,
|
||||
c: {
|
||||
action: Action.Send,
|
||||
data: makeReply(-1, 0, null),
|
||||
},
|
||||
d: {
|
||||
action: Action.Receive,
|
||||
subset: {
|
||||
type: 'reply',
|
||||
id: -1,
|
||||
result: null,
|
||||
},
|
||||
},
|
||||
e: { action: Action.IsReady, value: true },
|
||||
},
|
||||
}));
|
||||
|
||||
it('should reject methods from invalid service IDs', () =>
|
||||
testMarbles({
|
||||
rpcInstance: '---',
|
||||
|
|
10
src/rpc.ts
10
src/rpc.ts
|
@ -285,8 +285,14 @@ export class RPC extends EventEmitter {
|
|||
// calls starting from 0.
|
||||
|
||||
if (this.isReadySignal(packet)) {
|
||||
this.remoteProtocolVersion =
|
||||
packet.type === 'method' ? packet.params.protocolVersion : packet.result.protocolVersion;
|
||||
const params: { protocolVersion: string } | undefined =
|
||||
packet.type === 'method' ? packet.params : packet.result;
|
||||
if (params && params.protocolVersion) {
|
||||
this.remoteProtocolVersion = params.protocolVersion;
|
||||
} else {
|
||||
this.remoteProtocolVersion = this.remoteProtocolVersion;
|
||||
}
|
||||
|
||||
this.callCounter = 0;
|
||||
this.reorder.reset(packet.counter);
|
||||
this.emit('isReady', true);
|
||||
|
|
Загрузка…
Ссылка в новой задаче