Skip to content

Commit

Permalink
feat: log (#330)
Browse files Browse the repository at this point in the history
  • Loading branch information
cool-firer authored Oct 8, 2024
1 parent fea6e92 commit 2c3c0c1
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion packages/network-support/src/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ export function createFetch(
orderManager: OrderManager,
maxRetries = 5,
logger?: Logger,
overrideFetch?: typeof fetch
overrideFetch?: typeof fetch,
rid?: string
): (init: RequestInit) => Promise<Response> {
let retries = 0;
let triedFallback = false;
Expand Down Expand Up @@ -132,6 +133,16 @@ export function createFetch(
};
}
if (type === OrderType.fallback) {
logger?.info({
type: 'fallback',
deploymentId: orderManager.getProjectId(),
indexer: 'fallback',
requestId,
retry: retries,
fallbackServiceUrl: orderManager.fallbackServiceUrl,
rid,
status: _res.status,
});
res = await _res.json();
}

Expand Down Expand Up @@ -168,6 +179,7 @@ export function createFetch(
error: errorMsg,
stack: e.stack,
fallbackServiceUrl: orderManager.fallbackServiceUrl,
rid,
});
const extraLog = {
requestId,
Expand All @@ -190,6 +202,7 @@ export function createFetch(
error: errorMsg,
stack: e.stack,
fallbackServiceUrl: orderManager.fallbackServiceUrl,
rid,
});

throw new FetchError(errorMsg, 'SQN');
Expand All @@ -205,6 +218,7 @@ export function createFetch(
error: errorMsg,
stack: e.stack,
fallbackServiceUrl: orderManager.fallbackServiceUrl,
rid,
});

throw new FetchError(`reach max retries.${errorMsg ? ' error: ' + errorMsg : ''}`, 'SQN');
Expand Down

0 comments on commit 2c3c0c1

Please sign in to comment.