Skip to content

Comments

chore(PLA-2224): re-fetch guides when the existing socket is disconnected and reconnected#869

Open
jareddellitt wants to merge 6 commits intomainfrom
jdellitt/PLA-2224
Open

chore(PLA-2224): re-fetch guides when the existing socket is disconnected and reconnected#869
jareddellitt wants to merge 6 commits intomainfrom
jdellitt/PLA-2224

Conversation

@jareddellitt
Copy link
Contributor

Description

This will force re-fetch guides when the socket is reopened after a disconnection. This handles both deployments of the underlying sockets system and page visibility induced disconnections.

Checklist

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

@linear
Copy link

linear bot commented Feb 19, 2026

@changeset-bot
Copy link

changeset-bot bot commented Feb 19, 2026

🦋 Changeset detected

Latest commit: 58d3def

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
@knocklabs/client Patch
client-example Patch
guide-example Patch
@knocklabs/expo Patch
@knocklabs/react-core Patch
@knocklabs/react-native Patch
@knocklabs/react Patch
@knocklabs/expo-example Patch
ms-teams-connect-example Patch
nextjs-app-dir-example Patch
nextjs-example Patch
slack-connect-example Patch
slack-kit-example Patch

Not sure what this means? Click here to learn what changesets are.

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

@vercel
Copy link

vercel bot commented Feb 19, 2026

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

Project Deployment Actions Updated (UTC)
javascript-ms-teams-connect-example Ready Ready Preview, Comment Feb 19, 2026 0:40am
javascript-nextjs-example Ready Ready Preview, Comment Feb 19, 2026 0:40am
javascript-slack-connect-example Ready Ready Preview, Comment Feb 19, 2026 0:40am
javascript-slack-kit-example Ready Ready Preview, Comment Feb 19, 2026 0:40am

Request Review

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

@codecov
Copy link

codecov bot commented Feb 19, 2026

Codecov Report

❌ Patch coverage is 90.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.49%. Comparing base (04a8f16) to head (58d3def).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
packages/client/src/clients/guide/client.ts 90.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #869      +/-   ##
==========================================
+ Coverage   67.41%   67.49%   +0.08%     
==========================================
  Files         204      204              
  Lines        8561     8579      +18     
  Branches     1118     1127       +9     
==========================================
+ Hits         5771     5790      +19     
+ Misses       2766     2765       -1     
  Partials       24       24              
Files with missing lines Coverage Δ
packages/client/src/clients/guide/client.ts 89.26% <90.00%> (+0.33%) ⬆️

@jareddellitt jareddellitt marked this pull request as ready for review February 19, 2026 01:12
@jareddellitt jareddellitt requested review from a team, kylemcd and thomaswhyyou and removed request for a team February 19, 2026 01:13
Comment on lines +421 to +425
if (this.socketOpenListenerId) {
this.socket.off([this.socketOpenListenerId]);
this.socketOpenListenerId = undefined;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Could we move this to a private method and re-use here and in unsubscribe?

// If the socket is already connected, there's no initial open event coming,
// so we don't need to skip anything. If it's not yet connected, skip the
// first onOpen since that's the initial connection, not a reconnect.
let isFirstOpen = !this.socket.isConnected();
Copy link
Contributor

Choose a reason for hiding this comment

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

Given we call this.socket.connect() if this.socket.isConnected() is not true above, I would think this is always true by the time we get here, but maybe this is just for out of caution?

// so we don't need to skip anything. If it's not yet connected, skip the
// first onOpen since that's the initial connection, not a reconnect.
let isFirstOpen = !this.socket.isConnected();
this.socketOpenListenerId = this.socket.onOpen(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it fair to assume this will fire when we deploy switchboard? I guess switchboard-sockets specifically?

If so, I kinda want to avoid triggering ALL connected clients to re-fetch at the same time from a deploy. Curious if you have any thoughts on targeting re-connect events from the tab visibility state change more granularly? Those will happen more organically and spread out across connected clients, which I think is would be the right thing to do. But i'm a bit hesitant to just blanket re-fetch based on every socket onOpen events.

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