-
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
Provider-level offline support #354
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.
👍 Looks good to me! Reviewed everything up to 59135b9 in 55 seconds
More details
- Looked at
1273
lines of code in7
files - Skipped
0
files when reviewing. - Skipped posting
0
drafted comments based on config settings.
Workflow ID: wflow_QBW6xBQvEZGgykds
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 192922b in 16 seconds
More details
- Looked at
107
lines of code in1
files - Skipped
0
files when reviewing. - Skipped posting
2
drafted comments based on config settings.
1. js-pkg/client/src/indexeddb.ts:88
- Draft comment:
Ensure the transaction completes before proceeding by returning a promise that resolves on transaction completion. Also,objectCount
should be reset to 1 after clearing and adding the new state. - Reason this comment was not posted:
Comment did not seem useful.
2. js-pkg/client/src/indexeddb.ts:93
- Draft comment:
Consider handling transaction completion to ensure data consistency. - Reason this comment was not posted:
Marked as duplicate.
Workflow ID: wflow_ibOiqsqLjlX1duar
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.
❌ Changes requested. Incremental review on 2fe57df in 37 seconds
More details
- Looked at
174
lines of code in3
files - Skipped
0
files when reviewing. - Skipped posting
2
drafted comments based on config settings.
1. js-pkg/client/src/encryption.ts:1
- Draft comment:
Consider usingTextDecoder
andTextEncoder
for more efficient base64 conversion. - Reason this comment was not posted:
Confidence changes required:50%
ThearrayBufferToBase64
andbase64ToArrayBuffer
functions can be optimized using modern JavaScript methods.
2. js-pkg/client/src/indexeddb.ts:101
- Draft comment:
Consider adding error handling for the transaction insaveWholeState
to ensure data integrity. - Reason this comment was not posted:
Comment was on unchanged code.
Workflow ID: wflow_c9wc8eRtj5zHqx4k
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 4e06920 in 2 seconds
More details
- Looked at
28
lines of code in1
files - Skipped
0
files when reviewing. - Skipped posting
1
drafted comments based on config settings.
1. js-pkg/client/src/indexeddb.ts:82
- Draft comment:
Theasync
keyword is unnecessary here as there are no asynchronous operations inside theonsuccess
handler. Consider removing it. - Reason this comment was not posted:
Confidence changes required:50%
The use ofasync
in theonsuccess
handler is unnecessary since the handler itself does not perform any asynchronous operations.
Workflow ID: wflow_n9pzrN12eAmmuaHk
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.
Mostly style / conciseness related.
Re: compaction, is there a benefit to storing the last N updates individually in IndexedDB?
- If there is, we could iteratively compact the oldest two updates with
Y.mergeUpdates
. This means the oldest update will asymptotically grow to be the full update log, but we'll still have the newest 9 (for granular undo/redo? not sure) - If not, why not just serialize and store the full document every update? Is it just faster to only serialize the full update once every N times?
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 34a2bba in 12 seconds
More details
- Looked at
103
lines of code in1
files - Skipped
0
files when reviewing. - Skipped posting
2
drafted comments based on config settings.
1. js-pkg/client/src/provider.ts:277
- Draft comment:
ThereceiveSyncMessage
method was moved but not modified. Ensure that its new position is logical and consistent with the code structure. - Reason this comment was not posted:
Confidence changes required:20%
ThereceiveSyncMessage
andbroadcastAwareness
methods were moved but not modified. This is a refactor for better organization, not a functional change.
2. js-pkg/client/src/provider.ts:304
- Draft comment:
ThebroadcastAwareness
method was moved but not modified. Ensure that its new position is logical and consistent with the code structure. - Reason this comment was not posted:
Confidence changes required:20%
ThebroadcastAwareness
method was moved but not modified. This is a refactor for better organization, not a functional change.
Workflow ID: wflow_mxtPqMit9wAHS8vw
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 6d0d748 in 31 seconds
More details
- Looked at
87
lines of code in1
files - Skipped
0
files when reviewing. - Skipped posting
6
drafted comments based on config settings.
1. js-pkg/client/src/provider.ts:6
- Draft comment:
Consider using theEVENT_SYNC
constant instead of the hardcoded string 'sync' for consistency and maintainability.
const EVENT_SYNC = 'sync'
- Reason this comment was not posted:
Confidence changes required:50%
The PR introduces constants for message types, which is a good practice for readability and maintainability. However, the constants are not used consistently throughout the file. Specifically, theEVENT_SYNC
constant is defined but not used in theemit
method where the event name is hardcoded as 'sync'.
2. js-pkg/client/src/provider.ts:156
- Draft comment:
Consider using theEVENT_SYNC
constant instead of the hardcoded string 'sync' for consistency and maintainability.
this.emit(EVENT_SYNC, state)
- Reason this comment was not posted:
Confidence changes required:50%
The PR introduces constants for message types, which is a good practice for readability and maintainability. However, the constants are not used consistently throughout the file. Specifically, theEVENT_SYNC
constant is defined but not used in theemit
method where the event name is hardcoded as 'sync'.
3. js-pkg/client/src/provider.ts:272
- Draft comment:
Consider using theEVENT_SYNC
constant instead of the hardcoded string 'sync' for consistency and maintainability.
this.emit(EVENT_SYNC, state)
- Reason this comment was not posted:
Confidence changes required:50%
The PR introduces constants for message types, which is a good practice for readability and maintainability. However, the constants are not used consistently throughout the file. Specifically, theEVENT_SYNC
constant is defined but not used in theemit
method where the event name is hardcoded as 'sync'.
4. js-pkg/client/src/provider.ts:292
- Draft comment:
Consider using theEVENT_SYNC
constant instead of the hardcoded string 'sync' for consistency and maintainability.
this.emit(EVENT_SYNC, state)
- Reason this comment was not posted:
Confidence changes required:50%
The PR introduces constants for message types, which is a good practice for readability and maintainability. However, the constants are not used consistently throughout the file. Specifically, theEVENT_SYNC
constant is defined but not used in theemit
method where the event name is hardcoded as 'sync'.
5. js-pkg/client/src/provider.ts:307
- Draft comment:
Consider using theEVENT_SYNC
constant instead of the hardcoded string 'sync' for consistency and maintainability.
this.emit(EVENT_SYNC, state)
- Reason this comment was not posted:
Confidence changes required:50%
The PR introduces constants for message types, which is a good practice for readability and maintainability. However, the constants are not used consistently throughout the file. Specifically, theEVENT_SYNC
constant is defined but not used in theemit
method where the event name is hardcoded as 'sync'.
6. js-pkg/client/src/provider.ts:335
- Draft comment:
Consider using theEVENT_SYNC
constant instead of the hardcoded string 'sync' for consistency and maintainability.
this.emit(EVENT_SYNC, state)
- Reason this comment was not posted:
Confidence changes required:50%
The PR introduces constants for message types, which is a good practice for readability and maintainability. However, the constants are not used consistently throughout the file. Specifically, theEVENT_SYNC
constant is defined but not used in theemit
method where the event name is hardcoded as 'sync'.
Workflow ID: wflow_FVQ1Bb6xNTtA6KSi
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 7115067 in 9 seconds
More details
- Looked at
21
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:435
- Draft comment:
Consider renaming_on
to something more descriptive likeaddListener
to clarify its purpose and avoid confusion with theon
method. - Reason this comment was not posted:
Confidence changes required:50%
The code in the PR modifies the_on
method to handleonce
listeners correctly. However, theon
method still directly calls_on
without checking foronce
. This could lead to confusion or errors ifon
is expected to handleonce
listeners as well.
Workflow ID: wflow_TTJ77kyeCqrDjn4H
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 0e6794b in 26 seconds
More details
- Looked at
37
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:357
- Draft comment:
Redundantconnect
calls whenshouldConnect
is true andisConnecting
is false. Consider refactoring to avoid repetition. This is also present inwebsocketError
andsetStatus
. - Reason this comment was not posted:
Comment looked like it was already resolved.
Workflow ID: wflow_hp5HkyMkWGs1qfWa
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
a22bde8
to
4e06920
Compare
4e06920
to
802be94
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 86b4557 in 22 seconds
More details
- Looked at
63
lines of code in2
files - Skipped
0
files when reviewing. - Skipped posting
2
drafted comments based on config settings.
1. examples/nextjs/src/app/(demos)/color-grid/page.tsx:9
- Draft comment:
Unresolved merge conflict markers (e.g.,<<<<<<< HEAD
,=======
,>>>>>>>
) are present. These should be resolved before merging. - Reason this comment was not posted:
Comment looked like it was already resolved.
2. js-pkg/client/src/provider.ts:152
- Draft comment:
TheindexedDBProvider
is initialized but not used. Ensure it's utilized or remove it if unnecessary. - Reason this comment was not posted:
Comment did not seem useful.
Workflow ID: wflow_wzA4B2IkVs7MPVjW
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 7a9770e in 19 seconds
More details
- Looked at
28
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:361
- Draft comment:
The increment ofthis.retries
should occur before calculating the timeout to ensure the backoff logic is applied correctly. This applies to line 376 as well. - Reason this comment was not posted:
Comment looked like it was already resolved.
Workflow ID: wflow_sPNrMECP3h4Nkcrj
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 33c39b6 in 35 seconds
More details
- Looked at
100
lines of code in1
files - Skipped
0
files when reviewing. - Skipped posting
2
drafted comments based on config settings.
1. js-pkg/client/src/indexeddb.ts:96
- Draft comment:
Consider awaiting theloadFromDb
call to ensure that the database is fully loaded before proceeding with other operations. - Reason this comment was not posted:
Comment was on unchanged code.
2. js-pkg/client/src/indexeddb.ts:182
- Draft comment:
Clarify in the comment thatnull
is returned if the key already exists. - Reason this comment was not posted:
Confidence changes required:50%
TheinsertValue
method returnsnull
if the key already exists, but this is not clearly documented in the method's comment. The comment should explicitly mention thatnull
is returned when the key already exists.
Workflow ID: wflow_N13kBfKclVmiFTNH
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.
❌ Changes requested. Incremental review on e2255ab in 27 seconds
More details
- Looked at
15
lines of code in1
files - Skipped
0
files when reviewing. - Skipped posting
0
drafted comments based on config settings.
Workflow ID: wflow_Pc3xjLYw0thP55iP
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 20b167b in 47 seconds
More details
- Looked at
31
lines of code in1
files - Skipped
0
files when reviewing. - Skipped posting
2
drafted comments based on config settings.
1. js-pkg/client/src/provider.ts:356
- Draft comment:
The backoff calculation usesDELAY_MS_BEFORE_RETRY_TOKEN_REFRESH
instead ofDELAY_MS_BEFORE_RECONNECT
. This seems incorrect given the context of reconnecting after a failed token fetch.
DELAY_MS_BEFORE_RECONNECT *
- Reason this comment was not posted:
Comment looked like it was already resolved.
2. js-pkg/client/src/provider.ts:374
- Draft comment:
The backoff calculation usesDELAY_MS_BEFORE_RECONNECT
instead ofDELAY_MS_BEFORE_RETRY_TOKEN_REFRESH
. This seems incorrect given the context of retrying token refresh.
DELAY_MS_BEFORE_RETRY_TOKEN_REFRESH *
- Reason this comment was not posted:
Marked as duplicate.
Workflow ID: wflow_eYAhNEhvmXDKw0nV
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 7975284 in 24 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:175
- Draft comment:
The change fromPromise<IndexedDBProvider>
toIndexedDBProvider
is not handled correctly. The asynchronous nature ofcreateIndexedDBProvider
is ignored, which can lead to race conditions or unhandled promise rejections. Consider usingawait
properly or handling the promise correctly. - Reason this comment was not posted:
Comment looked like it was already resolved.
Workflow ID: wflow_EjTWgodeZssBhZp4
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 ba08aea in 43 seconds
More details
- Looked at
148
lines of code in10
files - Skipped
0
files when reviewing. - Skipped posting
8
drafted comments based on config settings.
1. examples/nextjs/src/app/(demos)/blocknote/page.tsx:8
- Draft comment:
Ensure that settingofflineSupport={true}
is intentional for all examples, as the default is nowfalse
. This is consistent with the PR description. - Reason this comment was not posted:
Confidence changes required:50%
The PR description mentions that the default value forofflineSupport
should befalse
, and the code reflects this change. However, the usage in the examples setsofflineSupport
totrue
. This is consistent with the intent to enable offline support in the examples.
2. examples/nextjs/src/app/(demos)/code-editor/page.tsx:8
- Draft comment:
Ensure that settingofflineSupport={true}
is intentional for all examples, as the default is nowfalse
. This is consistent with the PR description. - Reason this comment was not posted:
Confidence changes required:50%
The PR description mentions that the default value forofflineSupport
should befalse
, and the code reflects this change. However, the usage in the examples setsofflineSupport
totrue
. This is consistent with the intent to enable offline support in the examples.
3. examples/nextjs/src/app/(demos)/color-grid/page.tsx:9
- Draft comment:
Ensure that settingofflineSupport={true}
is intentional for all examples, as the default is nowfalse
. This is consistent with the PR description. - Reason this comment was not posted:
Confidence changes required:50%
The PR description mentions that the default value forofflineSupport
should befalse
, and the code reflects this change. However, the usage in the examples setsofflineSupport
totrue
. This is consistent with the intent to enable offline support in the examples.
4. examples/nextjs/src/app/(demos)/presence/page.tsx:8
- Draft comment:
Ensure that settingofflineSupport={true}
is intentional for all examples, as the default is nowfalse
. This is consistent with the PR description. - Reason this comment was not posted:
Confidence changes required:50%
The PR description mentions that the default value forofflineSupport
should befalse
, and the code reflects this change. However, the usage in the examples setsofflineSupport
totrue
. This is consistent with the intent to enable offline support in the examples.
5. examples/nextjs/src/app/(demos)/slate/page.tsx:8
- Draft comment:
Ensure that settingofflineSupport={true}
is intentional for all examples, as the default is nowfalse
. This is consistent with the PR description. - Reason this comment was not posted:
Confidence changes required:50%
The PR description mentions that the default value forofflineSupport
should befalse
, and the code reflects this change. However, the usage in the examples setsofflineSupport
totrue
. This is consistent with the intent to enable offline support in the examples.
6. examples/nextjs/src/app/(demos)/text-editor/page.tsx:8
- Draft comment:
Ensure that settingofflineSupport={true}
is intentional for all examples, as the default is nowfalse
. This is consistent with the PR description. - Reason this comment was not posted:
Confidence changes required:50%
The PR description mentions that the default value forofflineSupport
should befalse
, and the code reflects this change. However, the usage in the examples setsofflineSupport
totrue
. This is consistent with the intent to enable offline support in the examples.
7. examples/nextjs/src/app/(demos)/to-do-list/page.tsx:8
- Draft comment:
Ensure that settingofflineSupport={true}
is intentional for all examples, as the default is nowfalse
. This is consistent with the PR description. - Reason this comment was not posted:
Confidence changes required:50%
The PR description mentions that the default value forofflineSupport
should befalse
, and the code reflects this change. However, the usage in the examples setsofflineSupport
totrue
. This is consistent with the intent to enable offline support in the examples.
8. examples/nextjs/src/app/(demos)/tree-crdt/page.tsx:8
- Draft comment:
Ensure that settingofflineSupport={true}
is intentional for all examples, as the default is nowfalse
. This is consistent with the PR description. - Reason this comment was not posted:
Confidence changes required:50%
The PR description mentions that the default value forofflineSupport
should befalse
, and the code reflects this change. However, the usage in the examples setsofflineSupport
totrue
. This is consistent with the intent to enable offline support in the examples.
Workflow ID: wflow_owvupRxWzFtOTOfB
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 e48fa19 in 37 seconds
More details
- Looked at
19
lines of code in1
files - Skipped
0
files when reviewing. - Skipped posting
1
drafted comments based on config settings.
1. js-pkg/client/src/indexeddb.ts:128
- Draft comment:
Wraprequest.onerror
in a function to ensure it is called correctly.
request.onerror = () => reject(request.error)
- Reason this comment was not posted:
Comment was on unchanged code.
Workflow ID: wflow_50qivAq8u23fBLST
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
js-pkg/client/src/indexeddb.ts
Outdated
return new Promise<IDBDatabase>((resolve, reject) => { | ||
const request = indexedDB.open(name, 4) | ||
request.onupgradeneeded = (event: IDBVersionChangeEvent) => { | ||
const db = (event.target! as any).result as IDBDatabase |
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.
Is it possible to use request.result
here instead of (event.target! as any).result as IDBDatabase
?
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 f6ec496 in 4 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/indexeddb.ts:24
- Draft comment:
Consider adding error handling within theonupgradeneeded
event to manage potential errors during the object store creation. - Reason this comment was not posted:
Confidence changes required:50%
Theonupgradeneeded
event handler should handle errors that might occur during the creation of the object store.
Workflow ID: wflow_ZIh31zzFbvGddCvT
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
This builds on top of #352 to add offline support to the Y-Sweet provider. It's also exposed through the React bindings by passing
enableOfflineSupport={false,true}
toYDocProvider
.The approach is similar to
y-indexeddb
, where updates are stored incrementally and then compacted when the set of updates gets large.Browsers generally store indexeddb in plain text on disk. We encrypt the data using
AES-GCM
, and store the key in a cookie. Since cookies often store credentials, they are often treated more sensitively than local storage (Chrome encrypts them on disk, and stores the decryption key in the OS's keychain; Firefox and Safari still use plaintext.)Each document gets its own "database" in indexeddb, but the key is shared across the origin.
Since multiple tabs can have the same document open, they attempt to coordinate: