-
Notifications
You must be signed in to change notification settings - Fork 284
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add timeouts for request / response stream connections (#8434)
- Loading branch information
Showing
17 changed files
with
248 additions
and
70 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export { TimeoutTask } from './timeout.js'; | ||
export { TimeoutTask, executeTimeoutWithCustomError } from './timeout.js'; | ||
export { Timer } from './timer.js'; | ||
export { elapsed, elapsedSync } from './elapsed.js'; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** Individual request timeout error | ||
* | ||
* This error will be thrown when a request to a specific peer times out. | ||
* @category Errors | ||
*/ | ||
export class IndiviualReqRespTimeoutError extends Error { | ||
constructor() { | ||
super(`Request to peer timed out`); | ||
} | ||
} | ||
|
||
/** Collective request timeout error | ||
* | ||
* This error will be thrown when a req resp request times out regardless of the peer. | ||
* @category Errors | ||
*/ | ||
export class CollectiveReqRespTimeoutError extends Error { | ||
constructor() { | ||
super(`Request to all peers timed out`); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { type ConfigMapping, numberConfigHelper } from '@aztec/foundation/config'; | ||
|
||
export const DEFAULT_INDIVIDUAL_REQUEST_TIMEOUT_MS = 2000; | ||
export const DEFAULT_OVERALL_REQUEST_TIMEOUT_MS = 4000; | ||
|
||
// For use in tests. | ||
export const DEFAULT_P2P_REQRESP_CONFIG: P2PReqRespConfig = { | ||
overallRequestTimeoutMs: DEFAULT_OVERALL_REQUEST_TIMEOUT_MS, | ||
individualRequestTimeoutMs: DEFAULT_INDIVIDUAL_REQUEST_TIMEOUT_MS, | ||
}; | ||
|
||
export interface P2PReqRespConfig { | ||
/** | ||
* The overall timeout for a request response operation. | ||
*/ | ||
overallRequestTimeoutMs: number; | ||
|
||
/** | ||
* The timeout for an individual request response peer interaction. | ||
*/ | ||
individualRequestTimeoutMs: number; | ||
} | ||
|
||
export const p2pReqRespConfigMappings: Record<keyof P2PReqRespConfig, ConfigMapping> = { | ||
overallRequestTimeoutMs: { | ||
env: 'P2P_REQRESP_OVERALL_REQUEST_TIMEOUT_MS', | ||
description: 'The overall timeout for a request response operation.', | ||
...numberConfigHelper(DEFAULT_OVERALL_REQUEST_TIMEOUT_MS), | ||
}, | ||
individualRequestTimeoutMs: { | ||
env: 'P2P_REQRESP_INDIVIDUAL_REQUEST_TIMEOUT_MS', | ||
description: 'The timeout for an individual request response peer interaction.', | ||
...numberConfigHelper(DEFAULT_INDIVIDUAL_REQUEST_TIMEOUT_MS), | ||
}, | ||
}; |
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
Oops, something went wrong.