-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PLU-125: [EXCEL-12] After request checks (e.g. HTTP 429) (#375)
- Loading branch information
1 parent
9115115
commit df41a62
Showing
5 changed files
with
78 additions
and
9 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
packages/backend/src/apps/m365-excel/common/interceptors/request-error-handler.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import type { IApp } from '@plumber/types' | ||
|
||
import logger from '@/helpers/logger' | ||
|
||
const http429Handler: IApp['requestErrorHandler'] = async function ($, error) { | ||
if (error.response.status !== 429) { | ||
return | ||
} | ||
|
||
// A 429 response is considered a SEV-2+ incident for some tenants; log it | ||
// explicitly so that we can easily trigger incident creation from DD. | ||
logger.error('Received HTTP 429 from MS Graph', { | ||
event: 'm365-http-429', | ||
tenant: $.auth?.data?.tenantKey as string, | ||
baseUrl: error.response.config.baseURL, | ||
url: error.response.config.url, | ||
flowId: $.flow?.id, | ||
stepId: $.step?.id, | ||
executionId: $.execution?.id, | ||
}) | ||
|
||
// We don't want to retry 429s from M365, so convert it into a non-HttpError. | ||
throw new Error('Rate limited by Microsoft Graph.') | ||
} | ||
|
||
export default http429Handler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters