MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / docsProxyResponse

Function docsProxyResponse

apps/cloud/src/edge/passthrough.ts:88–121  ·  view source on GitHub ↗
(request: Request, pathname: string)

Source from the content-addressed store, hash-verified

86};
87
88export const docsProxyResponse = (request: Request, pathname: string): Promise<Response> =>
89 tracer.startActiveSpan(
90 `http.client ${request.method}`,
91 {
92 kind: SpanKind.CLIENT,
93 attributes: {
94 "server.address": DOCS_UPSTREAM_HOST,
95 "url.path": pathname,
96 "http.request.method": request.method,
97 },
98 },
99 async (span) => {
100 // oxlint-disable-next-line executor/no-try-catch-or-throw -- adapter boundary; observe upstream response/error for span status, then pass both through unchanged
101 try {
102 const response = await fetch(buildDocsUpstream(request));
103 span.setAttribute("http.response.status_code", response.status);
104 if (response.status >= 500) {
105 span.setStatus({ code: SpanStatusCode.ERROR, message: `HTTP ${response.status}` });
106 }
107 return response;
108 } catch (err) {
109 // oxlint-disable-next-line executor/no-instanceof-error, executor/no-unknown-error-message -- adapter boundary: fetch rejects untyped; normalized only for the OTel span record, the original error is rethrown below
110 const cause = err instanceof Error ? err : String(err);
111 span.recordException(cause);
112 // oxlint-disable-next-line executor/no-unknown-error-message -- adapter boundary: same normalization as the recordException line above
113 const message = typeof cause === "string" ? cause : cause.message;
114 span.setStatus({ code: SpanStatusCode.ERROR, message });
115 // oxlint-disable-next-line executor/no-try-catch-or-throw -- adapter boundary; preserve the original rejection for the platform handler
116 throw err;
117 } finally {
118 span.end();
119 }
120 },
121 );
122
123/**
124 * Answer a pure passthrough request without loading the Start server graph.

Callers 2

docs.tsFile · 0.90
passthroughResponseFunction · 0.85

Calls 4

buildDocsUpstreamFunction · 0.85
setAttributeMethod · 0.80
endMethod · 0.80
fetchFunction · 0.50

Tested by

no test coverage detected