Skip to content

requestTimeout >= 6000 doesn't work #1443

@thomasdax98

Description

@thomasdax98

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.

Metadata

Metadata

Assignees

Labels

closing-soonThis issue will automatically close in 2 days unless further comments are made.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions