Skip to content

WebSocket API Gateway PostToConnection command seemingly hangs forever #7632

@crispyricepc

Description

@crispyricepc

Checkboxes for prior research

Describe the bug

When calling PostToConnection to an endpoint that might not respond, no timeout is used even if one is set.

Regression Issue

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

SDK version number

@aws-sdk/client-apigatewaymanagementapi v3.965.0

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

v24.11.1

Reproduction Steps

Timeout appears to be ignored, which was observed in #6896 but closed prematurely.

Simple slow-responding server PoC

import express from "express";

const app = express();
const PORT = 3000;

async function response(req, res) {
  // Respond slowly
  await new Promise((resolve) => setTimeout(resolve, 10_000));
  res.send("hello");
}

app.use(response);

app.listen(PORT, (err) => {
  if (err) {
    console.error(err);
    return;
  }

  console.log(`Listening on port ${PORT}`);
});

Try to access this endpoint with a short timeout set

import {
  ApiGatewayManagementApiClient,
  PostToConnectionCommand,
} from "@aws-sdk/client-apigatewaymanagementapi";

const client = new ApiGatewayManagementApiClient({
  endpoint: "http://localhost:3000/",
  logger: console,
});

await client.send(
  new PostToConnectionCommand(
    {
      ConnectionId: "conn",
      Data: new TextEncoder().encode("hello"),
    },
    { requestTimeout: 5 }
  )
);

Observed Behavior

Process exited after 10 seconds

Expected Behavior

Process should have exited after 5 seconds (or 5 milliseconds, I couldn't find documentation on requestTimeout)

Possible Solution

No response

Additional Information/Context

No response

Metadata

Metadata

Assignees

Labels

p2This is a standard priority issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions