smithy-lang/smithy-typescript

ERR_HTTP2_STREAM_CANCEL is not retried

Closed this issue · 0 comments

I have a scenario when using @aws-sdk/client-kinesis where it occasionally throws an error with the code ERR_HTTP2_STREAM_CANCEL and cause with code ETIMEDOUT. Looking at the service-error-classification package, an error with code ETIMEDOUT would normally be retried, however being that node now wraps the timeout error in an http2 error, it isn't properly handled.

Below are the properties from one of the errors thrown.

property value
err.cause.address [REDACTED]
err.cause.code ETIMEDOUT
err.cause.errno -110
err.cause.message connect ETIMEDOUT IP_ADDRESS:443
err.cause.port 443
err.cause.stack Error: connect ETIMEDOUT IP_ADDRESS:443 at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1607:16)
err.cause.syscall connect
err.cause.type Error
err.code ERR_HTTP2_STREAM_CANCEL
err.message The pending stream has been canceled (caused by: connect ETIMEDOUT IP_ADDRESS:443)
err.stack Error [ERR_HTTP2_STREAM_CANCEL]: The pending stream has been canceled (caused by: connect ETIMEDOUT IP_ADDRESS:443) at closeSession (node:internal/http2/core:1175:20) at ClientHttp2Session.destroy (node:internal/http2/core:1565:5) at TLSSocket.socketOnError (node:internal/http2/core:3028:13) at TLSSocket.emit (node:events:519:28) at emitErrorNT (node:internal/streams/destroy:169:8) at emitErrorCloseNT (node:internal/streams/destroy:128:3) at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
err.type Error

In order to resolve, one option may be to add ERR_HTTP2_STREAM_CANCEL along with others to NODEJS_TIMEOUT_ERROR_CODES. Another maybe safer option could be to have error classification recursively walk the cause property of errors and consider those for classification.