MCPcopy Create free account
hub / github.com/github/copilot-sdk / run

Function run

nodejs/src/copilotRequestHandler.ts:355–377  ·  view source on GitHub ↗
(exchange: CopilotRequestExchange)

Source from the content-addressed store, hash-verified

353 }
354
355 async function run(exchange: CopilotRequestExchange): Promise<void> {
356 try {
357 await handler[kHandle](exchange);
358 if (!exchange.finished) {
359 await finalize(
360 exchange,
361 502,
362 "Copilot request handler returned without finalising the response (call responseBody.end() or .error())."
363 );
364 }
365 } catch (err) {
366 if (exchange.cancelled || exchange.signal.aborted) {
367 // The runtime already cancelled this request; the handler's
368 // throw is just the abort propagating out of its upstream call.
369 await finalize(exchange, 499, "Request cancelled by runtime", "cancelled");
370 return;
371 }
372 const message = err instanceof Error ? err.message : String(err);
373 await finalize(exchange, 502, message);
374 } finally {
375 pending.delete(exchange.requestId);
376 }
377 }
378
379 return {
380 async httpRequestStart(

Callers 1

httpRequestStartFunction · 0.85

Calls 3

finalizeFunction · 0.85
StringFunction · 0.85
deleteMethod · 0.45

Tested by

no test coverage detected