In sliding sync, with an empty list, it is possible for the proxy
to send back DELETE 0, INSERT 0 !room which has the net result of
`[!room]`. Previously, the JS SDK would not handle this correctly.
Now it does. With tests.
* feature detection code for thread list api
* fix bug where createThreadsTimelineSets would sometimes return nothing
* initial implementation of thread listing msc
* tests for thread list pagination
This is critical for calculating client-side push rules correctly.
Without it, the push processor may think rooms have a different
number of members, resulting typically in annoying failure modes
where rooms constantly make noises because the code thinks they
are 1:1 rooms.
* Small tidy-up to sync.ts
* Convert doSync into a while loop
* Apply `initialSyncLimit` only to initial syncs
* Convert matrix-client-syncing spec to TS
* Add tests around initial sync filtering
* Switch confusing filterId field for `filter`
* Tweak doSync error control flow
* Fix error control flow intricacies
* use includes
* Add tests
* Fix some strict mode errors
* Fix more strict mode errors
* Fix some strict mode errors
If you leave a room you can get a lone DELETE op.
If you join a room you can get a lone INSERT op.
Up until now, we've assumed these operations happen at the ends
of the list (e.g [0] or [length-1]) which is not guaranteed as it
depends on the sort order (e.g sort alphabetically and join a room
called 'D'). In this scenario, the indexes would not be tracked
correctly. Fixed with integration tests.
This can happen when you close your laptop overnight,
as the server will not hold onto in-memory resources
for your connection indefinitely. When this happen,
the server will HTTP 400 you with "session expired".
At this point, it is no longer safe to remember anything
and you must forget everything and resend any sticky
parameters. This commit does the sticky parameters and
re-establishes the connection, but it may need additional
work to make the JS SDK forget now invalid data.
This allows clients to know when a request has been applied
on the server. This allows us to change `resend(): void` to
`resend(): Promise<string>` which resolves/rejects with the
transaction ID when it has been applied/not.
* sliding sync: add client function and add stub sliding-sync.ts
Mostly c/p from sync.ts. Define interfaces for MSC3575 sliding
sync types. Complete WIP!
* Add core sliding sync classes
* Add integration tests for sliding sync api basics
* gut unused code; add more types
* Use SlidingSync in MatrixClient; stub functions for Sync
Enough to make ele-web actually load okay with 0 rooms.
* Start feeding through room data to the client
* Bugfixes so it sorta ish works
* Refactor the public API for sliding sync
Still needs some work but it's a start.
* Use EventEmitter for callbacks. Add ability to adjust lists and listen for list updates.
- Have atomic getList/setList operations on SlidingSync to update windows etc
- Add a list callback which is invoked with the list indicies and joined count.
* Add stub tests; add listenUntil to make tests easier to read
* No need to resend now
* Add more sliding sync tests; add new setListRanges function
* build tests upon one another to reduce boilerplate and c/p
* More thorough sliding sync tests
* Dependency inject SlidingSync in Client opts when calling startClient()
* Linting
* Fix crash when opts is undefined
* Fix up docs to make CI happy
* Remove all listeners when stop()d to allow for GC
* Add support for extensions
* Add ExtensionE2EE automatically if opts.crypto is present
* Add ExtensionToDevice automatically
* Bugfixes for to_device message processing
* default events to []
* bugfix: don't tightloop when the server is down
Caused by not detecting abort() correctly
* Return null for bad index positions
* Add getListData to get the initial calculated list response
* Add is_tombstoned
* More comments
* Add support for account data extension; rejig extension interface
* Handle invite_state
* Feed through prev_batch tokens
* Linting
* Fix tests
* Linting
* Iterate PR
* Iterate tests and remove unused code
* Update matrix-mock-request
* Make tests happier
* Remove DEBUG/debuglog and use logger.debug
* Update the API to the latest MSC; fixup tests
* Use undefined not null to make it work with the latest changes
* Don't recreate rooms when initial: true
* Add defensive code when unsigned.transaction_id is missing
We can still pair up events by looking at the event_id. We need
to do this in Sliding Sync because the proxy has limitations that
means it cannot guarantee it will always incude a transaction_id
in unsigned. The main reason why is due to the following race condition:
- A and B are in a DM room.
- Both are using the proxy.
- A says "hello".
- B's sync stream gets "hello" on the proxy. At this point the proxy
knows it needs to deliver it to A. It does so, but this event has
no transaction_id as it came down B's sync stream, not A's.
- If instead, A's sync stream gets "hello" on the proxy, the proxy
will deliver this message with the transaction_id correctly set.
There are no guarantees that A's sync stream will get the event in a
timely manner, hence the decision to just deliver the events as soon
as the proxy gets the event. This will not be an issue for native
Sliding Sync implementations; this is just a proxy issue.
* Linting
* Add additional sliding sync tests
* Begin adding SlidingSyncSdk tests
* Linting
* Add more sliding sync sdk tests
* Prep work for extension tests
* Linting
* Add account data extension tests
* add to-device tests
* Add E2EE extension tests
* Code smell fixes and extra tests
* Add test for no-txn-id local echo
* Add tests for resolveProfilesToInvites
* Add tests for moving entries down as well as up the list
* Remove conn-management.ts
* Actually verify the event was removed from the txn map
* Handle the case when /sync returns before /send without a txn_id
And ensure all the tests actually test the right things.
* Linting
Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
Events returned by the `/sync` endpoint, including relations bundled with other events, may have their `room_id`s stripped out. This causes decryption errors if the IDs aren't repopulated.
Fixesvector-im/element-web#22094.
* Fix test message utils using overload
* Tweak existing tests
* Add test around `MatrixClient::getEventTimeline`
* Fix test to actually exercise the faulty behaviour
* Extract timelineSet thread belongs logic and test it
* tweak method name
Inform the client that historical messages were imported in the timeline and they should refresh the timeline in order to see the new events.
Companion `matrix-react-sdk` PR: https://github.com/matrix-org/matrix-react-sdk/pull/8354
The `marker` events are being used as state now because this way they can't be lost in a timeline gap. Regardless of when they were sent, we will still have the latest version of the state to compare against. Any time we see our latest state value change for marker events, prompt the user that the timeline needs to refresh.
> In a [sync meeting with @ara4n](https://docs.google.com/document/d/1KCEmpnGr4J-I8EeaVQ8QJZKBDu53ViI7V62y5BzfXr0/edit#bookmark=id.67nio1ka8znc), we came up with the idea to make the `marker` events as state events. When the client sees that the `m.room.marker` state changed to a different event ID, it can throw away all of the timeline and re-fetch as needed.
>
> For homeservers where the [same problem](https://github.com/matrix-org/matrix-doc/pull/2716#discussion_r782499674) can happen, we probably don't want to throw away the whole timeline but it can go up the `unsigned.replaces_state` chain of the `m.room.marker` state events to get them all.
>
> In terms of state performance, there could be thousands of `marker` events in a room but it's no different than room members joining and leaving over and over like an IRC room.
>
> *-- https://github.com/matrix-org/matrix-spec-proposals/pull/2716#discussion_r782629097*
### Why are we just setting `timlineNeedsRefresh` (and [prompting the user](https://github.com/matrix-org/matrix-react-sdk/pull/8354)) instead of automatically refreshing the timeline for the user?
If we refreshed the timeline automatically, someone could cause your Element client to constantly refresh the timeline by just sending marker events over and over. Granted, you probably want to leave a room like this 🤷. Perhaps also some sort of DOS vector since everyone will be refreshing and hitting the server at the exact same time.
In order to avoid the timeline maybe going blank during the refresh, we could re-fetch the new events first, then replace the timeline. But the points above still stand on why we shouldn't.