MCPcopy
hub / github.com/triggerdotdev/trigger.dev / fetchWithInterceptors

Function fetchWithInterceptors

packages/trigger-sdk/src/v3/retry.ts:139–163  ·  view source on GitHub ↗
(
  input: RequestInfo | URL,
  init?: RequestInit
)

Source from the content-addressed store, hash-verified

137const fetchHttpHandlerStorage = new AsyncLocalStorage<Array<HttpHandler>>();
138
139const fetchWithInterceptors = async (
140 input: RequestInfo | URL,
141 init?: RequestInit
142): Promise<Response> => {
143 const handlers = fetchHttpHandlerStorage.getStore();
144
145 if (handlers) {
146 try {
147 const { getResponse } = await import("msw");
148
149 const request = new Request(input, init);
150
151 const response = await getResponse(handlers, request);
152
153 if (response) {
154 return response;
155 }
156 } catch (e) {
157 // Do nothing
158 return fetch(input, init);
159 }
160 }
161
162 return fetch(input, init);
163};
164
165class FetchErrorWithSpan extends Error {
166 constructor(

Callers 1

doFetchRequestFunction · 0.85

Calls 2

fetchFunction · 0.50
getStoreMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…