Fix issue #2724 and forceReadonly API while connected#4239
Conversation
⯅ @fluidframework/base-host: +204 Bytes
⯅ @fluid-example/bundle-size-tests: +235 Bytes
Baseline commit: b289288 |
| const oldValue = this.readonly; | ||
| this._forceReadonly = readonly; | ||
| if (oldValue !== this.readonly) { | ||
| let reconnect = false; |
There was a problem hiding this comment.
I'm not certain reconnection is right flow.
We might be already connected as "read"
Also re-connecting as "read" can still give you "write" connection - server is free to give you more.
Also this._reconnectMode might be ReconnectMode.Never or ReconnectMode.Disabled, in such case we should not reconnect (this is checked in reconnectOnError(), which probably should be duplicated via assert connectCore(), but it also likely point out that we are better off using reconnectOnError() flow vs. manually disconnecting and reconnecting.
I'd rather either scope the usage of this API to disconnected state, OR not touch connection, but operate only with readonly property. Latter is simpler and feels better, but it breaks the assumption that we somewhat ride on here - that connection properties (like permissions, read-only, etc.) are changed only on granularity of connections.
There was a problem hiding this comment.
The point is not to switch the mode here, but we have to disconnect to switch to readonly, I can't use reconnectOnError here, because I needs to switch the readonly mode in between.
With this change, it would only reconnect if we switch from write to read, and it really does matter what permission the server give us. We don't rely on that to stop sending ops to the server, but explicity depend on the readonly flag.
Not touching the connection is where we have problems with the assert in the readonly event handler, because we can't replay the ops after we reconnect on the same connection.
Logically, this is an internal disconnect reconnect, not auto reconnect which I thought the reconnectMode is supposed to control. What is the usage of reconnectMode?
There was a problem hiding this comment.
It makes sense. One thing to consider though - this is not fully invisible to users. For example, if that functionality would have been applied to summarizing container, then it would puke, because it notices disconnects and stops.
But I guess we can leave with it.
There was a problem hiding this comment.
True..... may be we can disable this API for summarizing clients? I will leave it for now.
| // Document will have been marked clean on reconnection | ||
| assert.equal(wasMarkedCleanCount, 1, | ||
| "Document will have been marked clean on reconnection"); | ||
| container.forceReadonly(false); |
There was a problem hiding this comment.
not sure if you check anywhere, if not, can you please check that container is actually in read-only state after flipping true and is not after false?
The best way to validate it is to have a component that reports last seen "readonly" event on datastore runtime (I think)
There was a problem hiding this comment.
@vladris has a PR for some forceReadonly specific test. I will leave it to be added there.
agarwal-navin
left a comment
There was a problem hiding this comment.
The document dirty event part looks good to me.
Uh oh!
There was an error while loading. Please reload this page.