Skip to content

chore(PLA-4090): cache socket URLs with null expiration indefinitely - #1089

Closed
mattmikolay wants to merge 1 commit into
mattmik-pla-3932-js-sdk-connect-sockets-using-websocket-gatewayfrom
mattmik-pla-4090-js-sdk-allow-connecting-to-legacy-websocket-endpoint-via
Closed

mattmikolay wants to merge 1 commit into
mattmik-pla-3932-js-sdk-connect-sockets-using-websocket-gatewayfrom
mattmik-pla-4090-js-sdk-allow-connecting-to-legacy-websocket-endpoint-via

Conversation

@mattmikolay

@mattmikolay mattmikolay commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Description

This PR updates the socket URL caching logic added by #1085 so that when Switchboard's WebSocket gateway API endpoint (POST /v1/sockets/connect) returns a URL that does not expire, the API client caches the URL indefinitely.

When the gateway API endpoint returns the legacy WebSocket connect URL (wss://api.knock.app/ws/v1/websocket), the response includes an expires_at property set to null:

{
    "url": "wss://api.knock.app/ws/v1/websocket",
    "expires_at": null
}

This url is valid indefinitely, provided clients authenticate the request using a valid API key.

Checklist

  • Tests have been added for new features or major refactors to existing features.

Stack created with GitHub Stacks CLI • Give Feedback 💬

@mattmikolay
mattmikolay added this pull request to stack #1088 October 22, 2026 21:04
@vercel

vercel Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
javascript-ms-teams-connect-example Ready Ready Preview Oct 22, 2026 9:07pm UTC
javascript-nextjs-example Ready Ready Preview Oct 22, 2026 9:07pm UTC
javascript-slack-connect-example Ready Ready Preview Oct 22, 2026 9:07pm UTC
javascript-slack-kit-example Ready Ready Preview Oct 22, 2026 9:07pm UTC

Request Review

@changeset-bot

changeset-bot Bot commented Oct 22, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 3b20fb0

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@linear-code

linear-code Bot commented Oct 22, 2026

Copy link
Copy Markdown

PLA-4090

@codecov

codecov Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Bundle Report

Changes will increase total bundle size by 130 bytes (0.02%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
@knocklabs/client-client-cjs 61.98kB 58 bytes (0.09%) ⬆️
@knocklabs/client-client-esm 74.25kB 72 bytes (0.1%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: @knocklabs/client-client-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
gatewayTransport.mjs 46 bytes 3.11kB 1.5%
helpers.mjs 26 bytes 1.09kB 2.45%

Files in gatewayTransport.mjs:

  • ./src/gatewayTransport.ts → Total Size: 3.51kB

Files in helpers.mjs:

  • ./src/helpers.ts → Total Size: 1.26kB
view changes for bundle: @knocklabs/client-client-cjs

Assets Changed:

Asset Name Size Change Total Size Change (%)
gatewayTransport.js 36 bytes 2.46kB 1.48%
helpers.js 22 bytes 905 bytes 2.49%

Files in gatewayTransport.js:

  • ./src/gatewayTransport.ts → Total Size: 3.54kB

Files in helpers.js:

  • ./src/helpers.ts → Total Size: 1.28kB

@codecov

codecov Bot commented Oct 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.09%. Comparing base (def24a4) to head (3b20fb0).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@                                         Coverage Diff                                         @@
##           mattmik-pla-3932-js-sdk-connect-sockets-using-websocket-gateway    #1089      +/-   ##
===================================================================================================
+ Coverage                                                            76.04%   76.09%   +0.05%     
===================================================================================================
  Files                                                                  140      140              
  Lines                                                                 4495     4505      +10     
  Branches                                                              1310     1320      +10     
===================================================================================================
+ Hits                                                                  3418     3428      +10     
  Misses                                                                 977      977              
  Partials                                                               100      100              
Files with missing lines Coverage Δ
packages/client/src/gatewayTransport.ts 99.00% <100.00%> (+0.07%) ⬆️
packages/client/src/helpers.ts 100.00% <100.00%> (ø)

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not approved — this is a client SDK behavior change (socket URL caching), not an auto-release, dependency, or docs-only PR. Human review from the product team is needed; no reviewers were assigned in this run.

Open in Web View Automation 

Sent by Cursor Approval Agent: SDK approver

@mattmikolay

Copy link
Copy Markdown
Contributor Author

I’m closing this in favor of knocklabs/switchboard#8222.

@mattmikolay
mattmikolay deleted the mattmik-pla-4090-js-sdk-allow-connecting-to-legacy-websocket-endpoint-via branch October 23, 2026 17:23
@mattmikolay
mattmikolay restored the mattmik-pla-4090-js-sdk-allow-connecting-to-legacy-websocket-endpoint-via branch October 23, 2026 17:26

This branch was successfully deployed

4 active deployments
Preview – javascript-nextjs-example — 3b20fb0e Deployed Oct 22, 2026 by vercel[bot]
Preview – javascript-slack-kit-example — 3b20fb0e Deployed Oct 22, 2026 by vercel[bot]
Preview – javascript-ms-teams-connect-example — 3b20fb0e Deployed Oct 22, 2026 by vercel[bot]
Preview – javascript-slack-connect-example — 3b20fb0e Deployed Oct 22, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants