253
// Response envelope (has id and either result or error, no method).
254
if (hasId && !hasMethod && (hasKey(msg, { result: true }) || hasKey(msg, { error: true }))) {
256
this._log('warn', `unsolicited response id=${msg.id}`);
257
return;
258
}
260
>
const pending = this._pending.get(id);
261
>
if (!pending) {
262
this._log('warn', `unsolicited response id=${msg.id}`);
263
return;
264
}
266
>
if (hasKey(msg, { error: true }) && msg.error) {
267
pending.reject(new JsonRpcError(msg.error.code, msg.error.message, msg.error.data));
269
pending.resolve((msg as IWireResponseSuccess).result);
270
}
272
>
}
273
274
// Server→client request (has method + id).