-
Notifications
You must be signed in to change notification settings - Fork 33
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
Implement events for sync status #353
Implement events for sync status #353
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
2 Skipped Deployments
|
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.
❌ Changes requested. Reviewed everything up to fc6f466 in 45 seconds
More details
- Looked at
163
lines of code in3
files - Skipped
0
files when reviewing. - Skipped posting
2
drafted comments based on config settings.
1. js-pkg/client/src/provider.ts:404
- Draft comment:
Remove or replaceconsole.log
with a proper logging mechanism for production use. - Reason this comment was not posted:
Confidence changes required:50%
Theconsole.log
statement in theemit
function is likely for debugging purposes and should be removed or replaced with a proper logging mechanism before production.
2. js-pkg/client/src/provider.ts:415
- Draft comment:
Good practice to emit thesync
event when the initial sync state changes to notify listeners. - Reason this comment was not posted:
Confidence changes required:0%
ThesetSynced
method is used to emit thesync
event when the initial sync state changes. This is a good practice to notify listeners about the sync state.
Workflow ID: wflow_8NiC1LdksYthGKYd
Want Ellipsis to fix these issues? Tag @ellipsis-dev
in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
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.
👍 Looks good to me! Incremental review on 2e61e9f in 19 seconds
More details
- Looked at
25
lines of code in1
files - Skipped
0
files when reviewing. - Skipped posting
1
drafted comments based on config settings.
1. js-pkg/client/src/provider.ts:412
- Draft comment:
ThesetSynced
method is redundant sincethis.synced
is now public and can be updated directly. Consider removing this method and updatingthis.synced
directly where needed. - Reason this comment was not posted:
Comment was on unchanged code.
Workflow ID: wflow_7SPsxs2ao427rOT6
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
2e61e9f
to
5fd16c0
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.
👍 Looks good to me! Incremental review on 3b9ff80 in 60 minutes and 50 seconds
More details
- Looked at
12
lines of code in1
files - Skipped
0
files when reviewing. - Skipped posting
1
drafted comments based on config settings.
1. js-pkg/client/src/provider.ts:409
- Draft comment:
Good cleanup removing debug logging. - Reason this comment was not posted:
Confidence changes required:0%
The removal of the console.log is good - it was just debug logging that could be noisy. The PR is implementing sync status events which is a useful feature. The implementation looks solid with proper message handling and state tracking. No issues found.
Workflow ID: wflow_parflct7f7DdkDXn
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
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.
👍 Looks good to me! Incremental review on 2bc9ec2 in 33 minutes and 16 seconds
More details
- Looked at
13
lines of code in1
files - Skipped
0
files when reviewing. - Skipped posting
1
drafted comments based on config settings.
1. js-pkg/client/src/provider.ts:50
- Draft comment:
Good style improvement - adding space afternew
improves readability and is consistent with TypeScript style guides. - Reason this comment was not posted:
Confidence changes required:0%
Looking at the WebSocketPolyfillType type definition, I notice that the spacing in the constructor signature was changed fromnew(url: string | URL)
tonew (url: string | URL)
. This is a style change that improves readability by adding a space afternew
. The change is good and consistent with TypeScript style guides.
Workflow ID: wflow_VOXYvC3nM5EVDUfk
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
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.
👍 Looks good to me! Incremental review on 2bc9ec2 in 39 minutes and 22 seconds
More details
- Looked at
13
lines of code in1
files - Skipped
0
files when reviewing. - Skipped posting
1
drafted comments based on config settings.
1. js-pkg/client/src/provider.ts:50
- Draft comment:
Consider handling potential integer overflow forlastSyncSent
andlastSyncAcked
. Could reset both to 0 when they reach a large value, since only equality matters. - Reason this comment was not posted:
Confidence changes required:50%
The change in the PR is a minor formatting change. However, the codebase has a potential issue with integer overflow forlastSyncSent
andlastSyncAcked
. This should be addressed to ensure long-term stability.
Workflow ID: wflow_Aqf5ArtJkDaeP8HN
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
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.
👍 Looks good to me! Incremental review on 5fd16c0 in 66 minutes and 41 seconds
More details
- Looked at
14
lines of code in1
files - Skipped
0
files when reviewing. - Skipped posting
1
drafted comments based on config settings.
1. js-pkg/client/src/provider.ts:110
- Draft comment:
The sync status implementation looks good - removinginitialSync
and keepingsynced
aligns well with the more accurate sync status tracking described in the PR. - Reason this comment was not posted:
Confidence changes required:0%
Looking at the changes in the PR, I notice that theinitialSync
field was removed butsynced
is kept. This is good as it aligns with the PR description about making the sync status more accurate. The changes look correct and implement the sync status tracking as described in the PR description using lastSyncSent and lastSyncAcked. The implementation appears sound and matches the intended design.
Workflow ID: wflow_vWY9rGnhdZK14iRF
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
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.
👍 Looks good to me! Incremental review on 670edd3 in 65 minutes and 31 seconds
More details
- Looked at
15
lines of code in1
files - Skipped
0
files when reviewing. - Skipped posting
1
drafted comments based on config settings.
1. js-pkg/client/src/provider.ts:427
- Draft comment:
The removed auto-reconnect logic here could lead to missed reconnections in some edge cases. Consider adding back:
private setStatus(status: YSweetStatus) {
if (status.status === STATUS_DISCONNECTED && this.shouldConnect && !this.isConnecting) {
this.connect()
}
if (this.status.status !== status.status) {
this.status = status
this.emit('status', status)
}
}
- Reason this comment was not posted:
Comment looked like it was already resolved.
Workflow ID: wflow_glBHMMjz19aAFhAl
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
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.
👍 Looks good to me! Incremental review on 37fbd54 in 36 seconds
More details
- Looked at
77
lines of code in1
files - Skipped
0
files when reviewing. - Skipped posting
3
drafted comments based on config settings.
1. js-pkg/client/src/provider.ts:430
- Draft comment:
ThesetStatus
method emits an object with astatus
property, butYSweetStatus
is now a union of string literals. Consider updating the emitted value to match the new type definition.
this.emit('status', status)
- Reason this comment was not posted:
Comment looked like it was already resolved.
2. js-pkg/client/src/provider.ts:233
- Draft comment:
ThestatusListener
function should be updated to handleYSweetStatus
as a union of string literals, not an object.
let statusListener = (event: string) => {
- Reason this comment was not posted:
Comment was on unchanged code.
3. js-pkg/client/src/provider.ts:298
- Draft comment:
ThesetStatus
method is called with an object, butYSweetStatus
is now a union of string literals. Update the call to pass a string literal instead.
this.setStatus(STATUS_CONNECTING)
- Reason this comment was not posted:
Comment looked like it was already resolved.
Workflow ID: wflow_EcAYFYgUjAvv0uwk
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
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.
👍 Looks good to me! Incremental review on a5981a9 in 46 seconds
More details
- Looked at
717
lines of code in7
files - Skipped
0
files when reviewing. - Skipped posting
7
drafted comments based on config settings.
1. js-pkg/client/src/provider.ts:399
- Draft comment:
Theconnect()
method is called recursively inwebsocketClose
andwebsocketError
, which can lead to an infinite loop if the connection keeps failing. Consider adding a check to ensureconnect()
is not called if it's already in the process of connecting. - Reason this comment was not posted:
Comment looked like it was already resolved.
2. js-pkg/react/src/main.tsx:98
- Draft comment:
The variableisSynced
is misleading. Consider renaming it tohasLocalChanges
to better reflect its purpose. - Reason this comment was not posted:
Confidence changes required:50%
TheuseHasLocalChanges
hook inreact/src/main.tsx
usesuseState
to trackisSynced
, but the variable name is misleading. It should behasLocalChanges
to reflect its actual purpose.
3. js-pkg/react/src/main.tsx:100
- Draft comment:
The variableisSynced
is misleading. Consider renaming it tohasLocalChanges
to better reflect its purpose. - Reason this comment was not posted:
Confidence changes required:50%
TheuseHasLocalChanges
hook inreact/src/main.tsx
usesuseState
to trackisSynced
, but the variable name is misleading. It should behasLocalChanges
to reflect its actual purpose.
4. js-pkg/react/src/main.tsx:102
- Draft comment:
The variableisSynced
is misleading. Consider renaming it tohasLocalChanges
to better reflect its purpose. - Reason this comment was not posted:
Confidence changes required:50%
TheuseHasLocalChanges
hook inreact/src/main.tsx
usesuseState
to trackisSynced
, but the variable name is misleading. It should behasLocalChanges
to reflect its actual purpose.
5. js-pkg/react/src/main.tsx:120
- Draft comment:
Ensure that the initial state ofstatus
is correctly set from the provider. - Reason this comment was not posted:
Confidence changes required:30%
TheuseConnectionStatus
hook inreact/src/main.tsx
usesuseState
to trackstatus
, which is fine, but ensure that the initial state is correctly set from the provider.
6. js-pkg/react/src/main.tsx:122
- Draft comment:
Ensure that the initial state ofstatus
is correctly set from the provider. - Reason this comment was not posted:
Confidence changes required:30%
TheuseConnectionStatus
hook inreact/src/main.tsx
usesuseState
to trackstatus
, which is fine, but ensure that the initial state is correctly set from the provider.
7. js-pkg/react/src/main.tsx:124
- Draft comment:
Ensure that the initial state ofstatus
is correctly set from the provider. - Reason this comment was not posted:
Confidence changes required:30%
TheuseConnectionStatus
hook inreact/src/main.tsx
usesuseState
to trackstatus
, which is fine, but ensure that the initial state is correctly set from the provider.
Workflow ID: wflow_QfDHCg6Xjq4uz7zJ
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
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.
👍 Looks good to me! Incremental review on 33b6704 in 9 seconds
More details
- Looked at
159
lines of code in4
files - Skipped
0
files when reviewing. - Skipped posting
2
drafted comments based on config settings.
1. js-pkg/client/src/ws-status.ts:78
- Draft comment:
The change fromEVENT_CONNECTION_STATUS
toEVENT_STATUS
inemit
is intentional to unify event naming and aligns with the PR description's intent to handle sync status events. - Reason this comment was not posted:
Confidence changes required:0%
The change fromEVENT_CONNECTION_STATUS
toEVENT_STATUS
inemit
is intentional to unify event naming and aligns with the PR description's intent to handle sync status events.
2. tests/src/index.test.ts:137
- Draft comment:
The change fromawait createYjsProvider
tocreateYjsProvider
is intentional to remove unnecessaryawait
sincecreateYjsProvider
is not an async function. This change is consistent across multiple test cases. - Reason this comment was not posted:
Confidence changes required:0%
The change fromawait createYjsProvider
tocreateYjsProvider
in tests is intentional to remove unnecessaryawait
sincecreateYjsProvider
is not an async function. This change is consistent across multiple test cases.
Workflow ID: wflow_FCJZFKMXGGn2X3ec
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
This is extracted from #353 and includes only the server-side change. It adds a custom message type that simply echoes back the content it received. Since the server processes messages sequentially, this is a way for a client to confirm that a message has been processed: - send some message - send a sync status message with a nonce - when you have received a message with the same nonce back, you can assume the message has been processed
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.
👍 Looks good to me! Incremental review on 55b2d18 in 15 seconds
More details
- Looked at
92
lines of code in1
files - Skipped
0
files when reviewing. - Skipped posting
3
drafted comments based on config settings.
1. js-pkg/client/src/provider.ts:150
- Draft comment:
Consider logging a warning or error if the websocket is not open when attempting to send a message. This will help in debugging connection issues. - Reason this comment was not posted:
Confidence changes required:50%
Thesend
method is a good abstraction for sending messages over the websocket, but it should handle the case where the websocket is not open more gracefully.
2. js-pkg/client/src/provider.ts:174
- Draft comment:
Consider adding a warning log if the websocket is not connected when trying to send an update. This will help in identifying issues when updates are not being sent due to connection problems. - Reason this comment was not posted:
Confidence changes required:50%
Theupdate
method should log a warning if the websocket is not connected, similar to the previous implementation.
3. js-pkg/client/src/provider.ts:320
- Draft comment:
Use thesend
method instead of directly accessingthis.websocket?.send
for consistency and to ensure the websocket is open before sending. - Reason this comment was not posted:
Confidence changes required:50%
ThereceiveSyncMessage
method should use thesend
method for consistency and to ensure the websocket is open before sending.
Workflow ID: wflow_kJnrUYrFE63QYoBX
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
@@ -17,7 +17,6 @@ use futures::{SinkExt, StreamExt}; | |||
use serde::Deserialize; | |||
use serde_json::{json, Value}; | |||
use std::{ | |||
net::SocketAddr, |
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.
unrelated change that snuck in, but it's just removing an unnecessary import
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.
👍 Looks good to me! Incremental review on 42bd0f6 in 19 seconds
More details
- Looked at
66
lines of code in1
files - Skipped
0
files when reviewing. - Skipped posting
1
drafted comments based on config settings.
1. js-pkg/client/src/provider.ts:401
- Draft comment:
Consider adding a delay before callingthis.connect()
to prevent rapid reconnect attempts in case of persistent connection failures. - Reason this comment was not posted:
Comment was on unchanged code.
Workflow ID: wflow_U9MyA2D50RXSNiFf
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
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.
Only a couple minor comments but LGTM
js-pkg/client/src/provider.ts
Outdated
this.on(EVENT_CONNECTION_STATUS, statusListener) | ||
}) | ||
|
||
this.setupWs(clientToken) |
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.
Would you be opposed to inlining this? All the small methods that are only used once make the connection flow a bit difficult for me to follow.
} | ||
|
||
protected emit(eventName: YSweetEvent, data: any = null): void { | ||
public emit(eventName: YSweetEvent | YWebsocketEvent, data: any = null): void { |
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.
Why make this public?
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.
It's needed so that WebSocketCompatLayer
can emit its own events, unfortunately.
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.
👍 Looks good to me! Incremental review on a9f4610 in 6 seconds
More details
- Looked at
41
lines of code in2
files - Skipped
0
files when reviewing. - Skipped posting
1
drafted comments based on config settings.
1. tests/src/index.test.ts:11
- Draft comment:
The functionwaitForLocalChangesSync
has been removed fromutil.ts
. Ensure that no other parts of the codebase rely on this function, as its removal could lead to issues if still referenced elsewhere. - Reason this comment was not posted:
Confidence changes required:50%
The removal ofwaitForLocalChangesSync
seems intentional, but it's important to ensure that no other parts of the codebase rely on it.
Workflow ID: wflow_qeZddOZMwpEAJcmm
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
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.
👍 Looks good to me! Incremental review on 963f722 in 26 seconds
More details
- Looked at
53
lines of code in2
files - Skipped
0
files when reviewing. - Skipped posting
2
drafted comments based on config settings.
1. js-pkg/client/src/provider.ts:304
- Draft comment:
ThegenerateUrl
function is defined twice in this file. Consider removing one of the definitions to avoid redundancy. - Reason this comment was not posted:
Comment was on unchanged code.
2. js-pkg/client/src/provider.ts:301
- Draft comment:
ThegenerateUrl
function is defined twice in this file. Consider removing one of the definitions to avoid redundancy. - Reason this comment was not posted:
Marked as duplicate.
Workflow ID: wflow_3rvtxaMP6gmm5TP5
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
y-websocket
has asynced
flag, but it is a bit misleading because it only tells whether the initial handshake was completed. Knowing whether a document was synced in general fory-protocols
is a bit tricky, because we would need to compare the state vector and delete set.When using WebSockets, we can take advantage of the ordering guarantee and synchronous message processing in Y-Sweet to implement a very simple check of sync.
The client stores two numbers,
lastSyncSent
andlastSyncAcked
. When it sends an update to the server, it also incrementslastSyncSent
and then sends a separatemessageSyncStatus
message containing that number as the payload.When the server receives a
messageSyncStatus
, it simply echoes it verbatim. When the client receives themessageSyncStatus
in return, it updateslastSyncAcked
to the payload of the message.If
lastSyncAcked
=lastSyncSent
, we know that all messages since the last update have been processed. Otherwise, there are outstanding changes.This builds on #352 and will enable #306.
Demo:
Screen.Recording.2024-12-12.at.4.26.31.PM.mov