Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

requestTimeout >= 6000 doesn't work #1443

Closed
thomasdax98 opened this issue Nov 4, 2024 · 2 comments
Closed

requestTimeout >= 6000 doesn't work #1443

thomasdax98 opened this issue Nov 4, 2024 · 2 comments
Assignees
Labels
closing-soon This issue will automatically close in 2 days unless further comments are made.

Comments

@thomasdax98
Copy link

thomasdax98 commented Nov 4, 2024

Background

I'm using @aws-sdk/client-s3 to stream videos from an S3 bucket. I experienced issues with socket connections staying open forever if the video stream was interrupted. Thus, I tried setting requestTimeout = 15_000 to cleanup connections (as mentioned in the docs).

Problem

However, the requestTimeout didn't work. The request never timed out and the connection still stayed open forever. I experimented with different values and found that requestTimeout <= 5000 works. But values >= 6000 don't work.

Suspected root cause

I looked at the source code and found the following code:

if (0 < timeoutInMs && timeoutInMs < 6000) {
registerTimeout(0);
return 0;
}
return setTimeout(
registerTimeout.bind(null, timeoutInMs === 0 ? 0 : DEFER_EVENT_LISTENER_TIME),
DEFER_EVENT_LISTENER_TIME
);

The timeout is handled differently for values <= 6000. It seems to me as if the code for >= 6000 doesn't work correctly:

return setTimeout(
registerTimeout.bind(null, timeoutInMs === 0 ? 0 : DEFER_EVENT_LISTENER_TIME),
DEFER_EVENT_LISTENER_TIME
);

The code above was introduced in #1384 and released in v3.2.0.

I downgraded to version 3.1.4 where timeouts >= 6000 worked again.

@thomasdax98
Copy link
Author

@kuhe Any chance you could take a look at that?

@kuhe
Copy link
Contributor

kuhe commented Dec 23, 2024

Thanks for your report. A fix has been published to https://www.npmjs.com/package/@smithy/node-http-handler/v/3.3.3.

Your existing client should have a ^ range dependency on this package that allows you to bring in the fix by updating the lockfile, such as with a fresh install.

The AWS SDK will upgrade to this fixed version at a later date.

@kuhe kuhe added the closing-soon This issue will automatically close in 2 days unless further comments are made. label Dec 23, 2024
@kuhe kuhe closed this as completed Dec 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closing-soon This issue will automatically close in 2 days unless further comments are made.
Projects
None yet
Development

No branches or pull requests

2 participants