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

Function docsProxyResponse

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

Source from the content-addressed store, hash-verified

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