Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve socket server overload #536

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

szczz
Copy link
Member

@szczz szczz commented Feb 14, 2025

Changes

  • Updates the socket server and client side code to make use of broadcasts. Should resolve the overloading issue.

These changes have been deployed to dev so please test there.

Testing

Steps:

  1. Ensure you can perform all create, save, rename etc actions on a Storyline
  2. A Storyline should not be accessible from more than one tab
  3. Please ensure timeout logic works as expected. Currently set to 5 minutes with a 2 min warning.

This change is Reviewable

Copy link

Your demo site is ready! 🚀 Visit it here: https://ramp4-pcar4.github.io/storylines-editor/SocketServerFix

Copy link
Member

@mohsin-r mohsin-r left a comment

Choose a reason for hiding this comment

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

Reviewed 3 of 3 files at r1, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @szczz)


server/index.js line 586 at r1 (raw file):

// Used to broadcast messages to all connected clients
function broadcastToClients(message){

Curious why we need to broadcast a storyline's lock/unlock to all the clients, instead of only the client that requested it (which we already do below with the ws.send).


server/index.js line 626 at r1 (raw file):

                logger('INFO', `A client successfully locked the storyline ${uuid}.`);
                const secret = generateKey();
                lockedUuids[uuid] = { secret };

Since we just have one property now, we could probably go back storing the secret itself instead of an object with the secret inside it. But totally upto you since its a pedantic grouse.


src/stores/lockStore.ts line 82 at r1 (raw file):

            clearInterval(this.timeInterval);
            if (this.connected) {
                this.socket!.send(JSON.stringify({ uuid: this.uuid, user: this.userName, lock: false }));

I believe the username reference should be removed here? Doesn't seem to be anywhere else.

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