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

Add support for MSC3575: Sliding Sync #2242

Merged
merged 70 commits into from
Jul 12, 2022
Merged

Add support for MSC3575: Sliding Sync #2242

merged 70 commits into from
Jul 12, 2022

Conversation

kegsay
Copy link
Member

@kegsay kegsay commented Mar 16, 2022

This PR adds API support for Sliding Sync. This is a big change and can be broken down into sliding sync specific changes and general JS SDK changes (which are inherently more risky and needs closer attention).

JS SDK changes:

  • IRequestOpts in http-api.ts now accepts an optional baseUrl. It already accepts a prefix but that isn't enough for sliding sync because we want to redirect /sync requests to a different server entirely (the proxy server), hence this was added.
  • slidingSync has been added as a function to MatrixClient. This function just makes a /sync request: it doesn't handle the loop or retries.
  • IStartClientOpts in client.ts now accepts an optional slidingSync object, which must be of type SlidingSync. If this is present, JS SDK operates in Sliding Sync mode.

Sliding Sync changes:

  • Added new files:
    • sliding-sync.ts: contains the core sliding sync API and event loop handling. Does not handle interactions with JS SDK innards. Exposes an event emitter for sliding sync data.
    • siding-sync-sdk.ts: contains JS SDK <--> sliding sync data mappings. Listens for events emitted by SlidingSync.
    • conn-management.ts: factored out keep-alive code. Same as sync v2 otherwise.

Limitations:

  • The data mappings in sliding-sync-sdk.ts are very bare bones currently - only state/timeline events are handled (not ephemeral/account/to-device/E2EE). This will be expanded upon in the future.

Contains integration tests for SlidingSync. No tests exist yet for SlidingSyncSdk.


Here's what your changelog entry will look like:

✨ Features

@kegsay kegsay requested a review from a team as a code owner March 16, 2022 10:30
Copy link
Member

@dbkr dbkr left a comment

Choose a reason for hiding this comment

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

few minor comments but otherwise looks plausible!

spec/integ/matrix-client-sliding-sync.spec.js Outdated Show resolved Hide resolved
spec/integ/matrix-client-sliding-sync.spec.js Outdated Show resolved Hide resolved
src/sliding-sync-sdk.ts Outdated Show resolved Hide resolved
src/sliding-sync.ts Outdated Show resolved Hide resolved
src/sliding-sync.ts Outdated Show resolved Hide resolved
src/sliding-sync.ts Outdated Show resolved Hide resolved
@codecov-commenter

This comment was marked as outdated.

@@ -5888,6 +5899,9 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
// There can be only room-kind push rule per room
// and its id is the room id.
if (this.pushRules) {
if (!this.pushRules[scope] || !this.pushRules[scope].room) {
return;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Defensive programming when the server returns {}. There's no guarantees that scope will exist.

spec/unit/room.spec.ts Outdated Show resolved Hide resolved
@kegsay kegsay requested a review from t3chguy July 8, 2022 12:53
Copy link
Member

@t3chguy t3chguy left a comment

Choose a reason for hiding this comment

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

LGTM, will block until after RC branch cut tomorrow though!

@t3chguy t3chguy enabled auto-merge (squash) July 12, 2022 14:03
@t3chguy t3chguy merged commit 8d7eaa7 into develop Jul 12, 2022
@t3chguy t3chguy deleted the kegan/sync-v3 branch July 12, 2022 14:09
su-ex added a commit to SchildiChat/matrix-js-sdk that referenced this pull request Aug 22, 2022
* Remove unstable support for `m.room_key.withheld` ([\matrix-org#2512](matrix-org#2512)). Fixes matrix-org#2233.
* Sliding sync: add missing filters from latest MSC ([\matrix-org#2555](matrix-org#2555)).
* Use stable prefixes for MSC3827 ([\matrix-org#2537](matrix-org#2537)).
* Add support for MSC3575: Sliding Sync ([\matrix-org#2242](matrix-org#2242)).
* Correct the units in TURN servers expiry documentation ([\matrix-org#2520](matrix-org#2520)).
* Re-insert room IDs when decrypting bundled redaction events returned by `/sync` ([\matrix-org#2531](matrix-org#2531)). Contributed by @duxovni.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants