-
Notifications
You must be signed in to change notification settings - Fork 13
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
Conversation
Your demo site is ready! 🚀 Visit it here: https://ramp4-pcar4.github.io/storylines-editor/SocketServerFix |
There was a problem hiding this 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.
692ea38
to
0465138
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 1 of 3 files reviewed, 3 unresolved discussions (waiting on @mohsin-r)
server/index.js
line 586 at r1 (raw file):
Previously, mohsin-r (Mohsin Reza) wrote…
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
).
This is to prevent polling and repeated requests, in a way its a touch of future proofing as well.
The idea is if all clients are aware that a storyline has been locked, the client won't repeatedly try to access the storyline like we were seeing in the DB (refer to the screenshot I sent on teams). Essentially each client was doing this whenever it requested a locked storyline
Similarly, if we broadcast an unlock message, all clients are aware that a storyline can be accessed.
server/index.js
line 626 at r1 (raw file):
Previously, mohsin-r (Mohsin Reza) wrote…
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.
Donethanks
src/stores/lockStore.ts
line 82 at r1 (raw file):
Previously, mohsin-r (Mohsin Reza) wrote…
I believe the
username
reference should be removed here? Doesn't seem to be anywhere else.
Donethanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functionality and code looks fine to me, just logged 2 issues found with renaming that can be addressed in future: #538, #539
Reviewed 1 of 3 files at r1, 2 of 2 files at r2, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @mohsin-r)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 2 files at r2, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @szczz)
server/index.js
line 586 at r1 (raw file):
Previously, szczz (Matt Szczerba) wrote…
This is to prevent polling and repeated requests, in a way its a touch of future proofing as well.
The idea is if all clients are aware that a storyline has been locked, the client won't repeatedly try to access the storyline like we were seeing in the DB (refer to the screenshot I sent on teams). Essentially each client was doing this whenever it requested a locked storyline
Similarly, if we broadcast an unlock message, all clients are aware that a storyline can be accessed.
Gotcha
#525
Changes
These changes have been deployed to dev so please test there.
Testing
Steps:
This change is