Skip to content

Conversation

@siddsriv
Copy link
Contributor

@siddsriv siddsriv commented Dec 11, 2025

Issue

Internal JS-5193

Description

Support retries for EC2 IMDS requests and fetching tokens.

Testing

Unit tests:

 ✓ src/MetadataService.spec.ts (24 tests) 20ms
   ✓ MetadataService Socket Leak Checks > fetchMetadataToken - body consumption checks > should consume response body on 200 status and return token 5ms
   ✓ MetadataService Socket Leak Checks > fetchMetadataToken - body consumption checks > should consume response body on 400 status before throwing 2ms
.
.
.

   ✓ MetadataService Retry Configuration > status code handling for retries > should not retry 403 errors 0ms
   ✓ MetadataService Retry Configuration > status code handling for retries > should not retry 404 errors 0ms
   ✓ MetadataService Retry Configuration > status code handling for retries > should retry 401 errors 0ms
   ✓ MetadataService Retry Configuration > status code handling for retries > should retry 500 errors 0ms

 Test Files  1 passed (1)
      Tests  24 passed (24)
   Start at  23:37:49
   Duration  354ms (transform 72ms, setup 0ms, collect 96ms, tests 20ms, environment 0ms, prepare 78ms)

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@siddsriv siddsriv requested a review from a team as a code owner December 11, 2025 23:41
@siddsriv siddsriv changed the title feat(ec2-metadata-service): add retries feat(ec2-metadata-service): add retries for IMDS requests Dec 11, 2025
} else {
throw Object.assign(new Error(`Failed to fetch metadata token with status code ${response.statusCode}`), {
statusCode: response.statusCode,
$metadata: { httpStatusCode: response.statusCode },
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

slightly outside the scope of retries, but this is for consistency with the status code handling/assignment in request()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant