Skip to content

postToConnection request does not timeout even if requestTimeout is set. #6896

@MAD-Scotty

Description

@MAD-Scotty

Checkboxes for prior research

Describe the bug

When I try to post to a WebsocketMessage to my connections neither the postToConnection functions rejects an error nor it does resolves within the given requestTimeout. In the end I run into lambda timeout.

In some cases I have got lambda timeout for my lambda function which distributes messages to websocket connection. While debugging I added logging and found that in the cases the lambda times out the "Start sending connection.id" log is written but "Finished sending connection.id" log gets not written and for the same connection.id also the error log is not written. Therefore I assume the postToConnection function does not resolve or rejects even after the requestTimeout of 5sec is reached. The Lambda functions Timeout is set to 30sec.

async sendMessage(connection: WebsocketConnection, message: WebsocketMessage) {
        const data = new TextEncoder().encode(JSON.stringify(message));
        const postParams: PostToConnectionCommandInput = {
            ConnectionId: connection.id,
            Data: data,
        };

        try {
            logger.debug(`Start sending ${connection.id}`);
            await this.client.postToConnection(postParams, { requestTimeout: 5000 });
            logger.debug(`Finished sending ${connection.id}`);
        } catch (err) {
            logger.error(`Could not send to connectionId ${connection.id}`, err);
            await this.removeConnection(connection.id);
        }
    }

Regression Issue

  • Select this option if this issue appears to be a regression.

SDK version number

@aws-sdk/[email protected]

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

Node.js 20.x

Reproduction Steps

I do not not know why it appears, that the postToConnection function does not resolves or rejects.

Observed Behavior

Sometimes but not every time the postToConnection function does not resolve or reject.

Expected Behavior

I would expect postToConnection to reslove or reject at least after the requestTimeout is reached.

Possible Solution

No response

Additional Information/Context

No response

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.closed-for-stalenessp2This is a standard priority issueresponse-requestedWaiting on additional info and feedback. Will move to \"closing-soon\" in 7 days.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions