feat: add pluggable transport interface for sagemaker support#492
Merged
Conversation
85b06a8 to
b82d30b
Compare
VWang1111
approved these changes
May 27, 2026
CustomDeepgramClientOptions now accepts a `reconnect?: boolean` that controls whether the SDK retries streaming connections at the wrapper level after a transport-side failure. Defaults to `true`. When a `transportFactory` is supplied, `reconnect` is auto-set to `false` so self-retrying transports (e.g. SageMaker) aren't double-stacked with a second retry layer — wrapping a self-retrying transport caused storm-on-storm behavior under burst load. Pass `reconnect: true` with `transportFactory` to opt back into wrapper-level retries. TransportWebSocketAdapter honors the flag by short-circuiting its retry loop after the first attempt when reconnect is disabled, so transport-side errors surface to the application instead of being absorbed into another reconnect cycle.
b82d30b to
8dec8c9
Compare
GregHolmes
added a commit
that referenced
this pull request
Jun 1, 2026
🤖 I have created a release *beep* *boop* --- ## [5.4.0](v5.3.0...v5.4.0) (2026-06-01) Adds a pluggable streaming-transport layer (the JS side of the cross-SDK SageMaker work) and fixes the TypeScript types exposed for the WebSocket helper clients. Fully backwards-compatible — every new option is optional with existing defaults, so current callers need no code changes. ### Features * **Pluggable transport interface for SageMaker support** ([#492](#492)) ([4d43b1b](4d43b1b)) Adds a `DeepgramTransport` / `DeepgramTransportFactory` interface (`src/transport.ts`) and a `transportFactory` option on `DeepgramClient`. When set, the `listen.v1`, `listen.v2`, `speak.v1`, and `agent.v1` `createConnection` paths route through a custom transport via a `TransportWebSocketAdapter` instead of the default WebSocket; REST behaviour is unchanged. This is the seam the `@deepgram/sagemaker` package plugs into, validated end-to-end against live Nova-3 STT, Flux, and Aura TTS endpoints (including a 400-concurrent-connection burst). Mirrors the same work in the Python and Java SDKs. * **`reconnect` flag with auto-disable for custom transports** ([8dec8c9](8dec8c9)) New optional `reconnect?: boolean` on `DeepgramClient` (default `true`, exposed read-only as `client.reconnect`) controlling wrapper-level retry of streaming connections. Auto-disabled to `false` when a `transportFactory` is supplied, so self-retrying transports aren't double-stacked with a second retry layer (which caused storm-on-storm behaviour under burst load). Opt back in with an explicit `reconnect: true`. ### Bug Fixes * **Expose WebSocket helper types** ([#501](#501)) ([ac71def](ac71def)) — thanks @asim48-ctrl The `agent` / `listen` / `speak` getters were typed against the generated client, which hid the wrapper's `createConnection()` method and typed `Authorization` as required. They now expose typed WebSocket wrapper clients, so `client.listen.v1.createConnection({ model: "nova-3" })` type-checks and `Authorization` is optional. Runtime behaviour is unchanged — this is a types-only fix. Fixes #489. --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
GregHolmes
added a commit
to deepgram/deepgram-python-sdk
that referenced
this pull request
Jun 1, 2026
🤖 I have created a release *beep* *boop* --- ## [7.3.0](v7.2.0...v7.3.0) (2026-06-01) ### Features * **client:** add a declarative `reconnect` flag with transport-factory auto-disable. `DeepgramClient` / `AsyncDeepgramClient` now accept `reconnect: bool = True` (exposed read-only as `client.reconnect`). When a custom `transport_factory` is supplied, `reconnect` auto-sets to `False` to signal that the transport owns its own retry/reconnect lifecycle — e.g. the SageMaker transport's jittered backoff + replay buffers — so SDK-level retries don't stack on top and cause storm-on-storm under burst load. Pass `reconnect=True` explicitly to opt back in. Declarative only for now (the Python SDK has no wrapper reconnect layer; `websockets` doesn't auto-reconnect), fully backwards-compatible, and parity with the same flag in the JS ([#492](deepgram/deepgram-js-sdk#492)) and Java SDKs ([#720](#720)) ([b5d5905](b5d5905)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Greg Holmes <greg.holmes@deepgram.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes
Adds a pluggable streaming-transport interface so the JS SDK can route
listen.v1,listen.v2,speak.v1, andagent.v1connections through a custom transport instead of the default WebSocket. Also adds areconnectparity flag for clean handoff of retry responsibility to custom transports.This is the JS half of the cross-SDK pluggable-transport work that's also landed in Python and Java for SageMaker support.
What's new
DeepgramTransport/DeepgramTransportFactoryinterface (src/transport.ts)factory(url, headers, request)shape as the Python/Java equivalents, with JS-specific request metadata as a third argumenttransportFactoryoption onDeepgramClient(wired insrc/CustomClient.ts)listen.v1/listen.v2/speak.v1/agent.v1createConnectionpaths build aTransportWebSocketAdapterthat exposes the SDK's expectedReconnectingWebSocketsurface but delegates to the custom transport underneathreconnectflag with auto-disable (commitb82d30b)reconnect?: booleanoption onDeepgramClienttrue(SDK manages reconnects, current behaviour)transportFactoryis set, auto-disabled tofalse— the custom transport owns its retry/reconnect lifecycle; double-stacking the SDK's wrapper retries on top would cause storm-on-storm under burst loadreconnect: trueclient.reconnectContext
@deepgram/sagemaker(deepgram-js-sdk-transport-sagemaker) plugs into. That package'screateSageMakerTransportFactoryreturns aDeepgramTransportFactorymatching this interface.reconnectflag mirrors the same parity work in:deepgram-java-sdkdeepgram-python-sdk#720Testing
pnpm buildpnpm vitest run tests/unit/transport-factory.test.ts— adapter-path unit coverage including reconnect-flag defaults, explicitreconnect: false,transportFactoryauto-disable, and explicitreconnect: trueoverridepnpm vitest run tests/unit/custom-client.test.ts@deepgram/sagemakerpackage for the transport implementation those tests exerciseTypes of changes
Release impact
feat:per commit message → minor version bump per release-pleasetransportFactoryandreconnectare optional kwargs with sensible defaults; existing callers need no code changes.fernignoreso Fern regen doesn't overwrite themCompanion packages
This PR provides the SDK-side interface. The first consumer is:
@deepgram/sagemaker(repo:deepgram-js-sdk-transport-sagemaker) — SageMaker bidirectional HTTP/2 transport, validated end-to-end at 400 concurrent connectionsChecklist