-
-
Notifications
You must be signed in to change notification settings - Fork 831
Add mechanism to check only one instance of the app is running #11416
Conversation
This isn't used yet, but will form part of the solution to element-hq/element-web#25157.
0ba71b0
to
3fb3504
Compare
Shouldn't this be at the js-sdk level given the issue is multiple js-sdk instances connected to the same underlying storages? |
Well, maybe. But it's going to have to be called by the application, so at best it could be a utility that the js-sdk provides. As I see it: it's part of the js-sdk's contract that only one instance is connected at once. It's up to the application to enforce that. |
b3bee0d
to
203ddd2
Compare
The coverage metric is a lie. It's underreporting because I've had to disable coverage reporting on the new file. |
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.
Can you exclude it from the coverage reqs so Sonar passes you using https://github.com/vector-im/element-web/blob/develop/CONTRIBUTING.md#tests
// getSessionLock is piped into a different JS context via stringification, and the coverage functionality is | ||
// not available in that contest. So, turn off coverage instrumentation for it. | ||
"!<rootDir>/src/utils/SessionLock.ts", |
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.
As I wrote in #element-dev
, I've yet to think of a better solution to this.
This reverts commit 80c4336.
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.
We normally prevent dead code from entering the repo via automation, the automation is faulty but even so I'm not sure we should be adding code before we actually use it - https://github.com/matrix-org/matrix-react-sdk/actions/runs/5880603401/job/15947257227?pr=11416
well, don't mind keeping this PR on hold for now. I just wanted to keep the low-level mechanics separate from the application-level changes. |
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 sane otherwise, might it be worth considering namespacing in the ping/owner/claimant keys for when we eventually have multi-account support given presumably we'll be able to support opening different accounts in different tabs without this lockout
const sleepPromise = new Promise((resolve) => { | ||
setTimeout(resolve, remaining, undefined); | ||
}); |
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.
js-sdk utils has a sleep function which does just this
I'm not convinced it will, tbh. I guess it depends how we expect multi-account support to work - in particular around what happens when you open and close tabs. Suppose I go to https://app.element.io and log in to two accounts. If I then open a new tab on https://app.element.io, then I expect the new tab to be connected to those same two accounts, right? So the upshot is that all element-web tabs on the same host/browser are connected to the same set of accounts, and we only want one of them. |
…lockout/01_session_lock
This isn't used yet, but will form part of the solution to element-hq/element-web#25157.
This change is marked as an internal change (Task), so will not be included in the changelog.