smithy-lang/smithy-typescript

`requestTimeout >= 6000` doesn't work

Closed this issue · 2 comments

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.

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

kuhe commented

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.