359
360
request<M extends ClientRequestMethod, R = unknown>(
362
>
params: ClientRequestParams<M>,
363
>
): Promise<R> {
364
>
if (this._disposed) {
365
return Promise.reject(new CancellationError());
366
}
368
return Promise.reject(new JsonRpcError(JsonRpcErrorCode.InternalError, 'transport has exited'));
369
}
371
>
return new Promise<R>((resolve, reject) => {
372
>
this._pending.set(id, { method, resolve: resolve as (v: unknown) => void, reject });
373
>
const ok = this._writeMessage({ id, method, params });
374
>
if (!ok) {
375
this._pending.delete(id);
376
reject(new JsonRpcError(JsonRpcErrorCode.InternalError, 'write failed; transport closed'));
377
}
379
>
}
380
381
notify<M extends ClientNotificationMethod>(