Merge branch 'main' into fix-reset-timeout-on-progress
This commit is contained in:
commit
deb2737d0f
2 changed files with 465 additions and 30 deletions
|
|
@ -88,6 +88,11 @@ export type RequestHandlerExtra = {
|
|||
* An abort signal used to communicate if the request was cancelled from the sender's side.
|
||||
*/
|
||||
signal: AbortSignal;
|
||||
|
||||
/**
|
||||
* The session ID from the transport, if available.
|
||||
*/
|
||||
sessionId?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -310,9 +315,15 @@ export abstract class Protocol<
|
|||
const abortController = new AbortController();
|
||||
this._requestHandlerAbortControllers.set(request.id, abortController);
|
||||
|
||||
// Create extra object with both abort signal and sessionId from transport
|
||||
const extra: RequestHandlerExtra = {
|
||||
signal: abortController.signal,
|
||||
sessionId: this._transport?.sessionId,
|
||||
};
|
||||
|
||||
// Starting with Promise.resolve() puts any synchronous errors into the monad as well.
|
||||
Promise.resolve()
|
||||
.then(() => handler(request, { signal: abortController.signal }))
|
||||
.then(() => handler(request, extra))
|
||||
.then(
|
||||
(result) => {
|
||||
if (abortController.signal.aborted) {
|
||||
|
|
|
|||
|
|
@ -41,4 +41,9 @@ export interface Transport {
|
|||
* Callback for when a message (request or response) is received over the connection.
|
||||
*/
|
||||
onmessage?: (message: JSONRPCMessage) => void;
|
||||
|
||||
/**
|
||||
* The session ID generated for this connection.
|
||||
*/
|
||||
sessionId?: string;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue