Skip to content

Commit

Permalink
Merge pull request #49 from kaleido-io/req-timeout
Browse files Browse the repository at this point in the history
Setting a Default Request Timeout for REST API Calls
  • Loading branch information
gabriel-indik authored Dec 9, 2021
2 parents 2a4cbb1 + dfd9f40 commit 69ad14c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/handlers/blobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export const deliverBlob = async ({ blobPath, recipient, recipientURL, requestID
url: `${recipientURL}/api/v1/blobs${blobPath}`,
data: formData,
headers: formData.getHeaders(),
timeout: utils.constants.REST_API_CALL_BLOB_REQUEST_TIMEOUT,
httpsAgent
});
eventEmitter.emit('event', {
Expand Down
5 changes: 4 additions & 1 deletion src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,14 @@ export const constants = {
TRANSFER_HASH_ALGORITHM: 'sha256',
REST_API_CALL_MAX_ATTEMPTS: 5,
REST_API_CALL_RETRY_DELAY_MS: 500,
REST_API_CALL_REQUEST_TIMEOUT: 5000,
REST_API_CALL_BLOB_REQUEST_TIMEOUT: 60000,
MAX_EVENT_QUEUE_SIZE: 1000,
HASH_HEADER_NAME: 'dx-hash',
LAST_UPDATE_HEADER_NAME: 'dx-last-update'
};
const log = new Logger('utils.ts')
const log = new Logger('utils.ts');
axios.defaults.timeout = constants.REST_API_CALL_REQUEST_TIMEOUT;

export const regexp = {
FILE_KEY: /^(\/[a-z0-9\+\-\_\.]+)+$/i,
Expand Down

0 comments on commit 69ad14c

Please sign in to comment.