MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / fetchWithReport

Function fetchWithReport

packages/server-e2e/src/report.ts:152–196  ·  view source on GitHub ↗
(
  input: Parameters<typeof fetch>[0],
  init?: Parameters<typeof fetch>[1],
  options?: FetchWithReportOptions,
)

Source from the content-addressed store, hash-verified

150}
151
152export async function fetchWithReport(
153 input: Parameters<typeof fetch>[0],
154 init?: Parameters<typeof fetch>[1],
155 options?: FetchWithReportOptions,
156): Promise<Response> {
157 const fetchImpl = options?.fetchImpl ?? fetch;
158 const method = fetchMethod(input, init);
159 const url = fetchUrl(input);
160 const path = options?.path ?? pathFromUrl(url);
161 const startedAt = Date.now();
162 let response: Response;
163 try {
164 response = await fetchImpl(input, init);
165 } catch (error) {
166 recordReportEvent(
167 {
168 kind: 'http',
169 method,
170 path,
171 url,
172 durationMs: Date.now() - startedAt,
173 request: requestForFetchReport(input, init),
174 error: errorForReport(error),
175 },
176 { reportDir: options?.reportDir },
177 );
178 throw error;
179 }
180
181 const text = await response.clone().text();
182 recordReportEvent(
183 {
184 kind: 'http',
185 method,
186 path,
187 url,
188 status: response.status,
189 durationMs: Date.now() - startedAt,
190 request: requestForFetchReport(input, init),
191 response: responseForReport(text),
192 },
193 { reportDir: options?.reportDir },
194 );
195 return response;
196}
197
198export function defaultReportDir(): string {
199 return resolve(process.env['KIMI_SERVER_E2E_REPORT_DIR'] ?? join(process.cwd(), 'reports', 'latest'));

Callers 15

fetchEnvelopeFunction · 0.90
injectActivePromptFunction · 0.90
fetchDebugStateFunction · 0.90
fetchDispatchLogFunction · 0.90
injectActivePromptFunction · 0.90
report.test.tsFile · 0.90
daemonReachableFunction · 0.85
getEnvelopeFunction · 0.85
daemonReachableFunction · 0.85
debugPromptsReachableFunction · 0.85
injectActivePromptFunction · 0.85
daemonReachableFunction · 0.85

Calls 9

fetchMethodFunction · 0.85
fetchUrlFunction · 0.85
pathFromUrlFunction · 0.85
recordReportEventFunction · 0.85
requestForFetchReportFunction · 0.85
responseForReportFunction · 0.85
errorForReportFunction · 0.70
nowMethod · 0.65
textMethod · 0.65

Tested by 10

daemonReachableFunction · 0.68
getEnvelopeFunction · 0.68
daemonReachableFunction · 0.68
debugPromptsReachableFunction · 0.68
injectActivePromptFunction · 0.68
daemonReachableFunction · 0.68
daemonReachableFunction · 0.68
debugPromptsReachableFunction · 0.68
injectActivePromptFunction · 0.68
daemonReachableFunction · 0.68