-
Notifications
You must be signed in to change notification settings - Fork 535
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 closed flag to prevent latent socket emission #3787
Conversation
// We set the closed flag as a part of the contract for overriding the disconnect method. This is used by | ||
// DocumentDeltaConnection to determine if emitting on the socket is allowed, which is important since | ||
// OdspDocumentDeltaConnection reuses the socket rather than truly disconnecting it. | ||
this.closed = true; |
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.
i don't love this. i'm alway wary of flag as they make the state machine harder to understand. I also don't like having to reach into the shared implementation. Howerver, if we think this will get better soon-ish with refactoring i think it's ok.
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.
My hope is this all gets simpler with refactoring or BatchManager
removal per #3788. Agreed on wanting to minimize state management.
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.
Given that this will get cleaned up a bit with the batchmanager removal, looks good to me if you don't think adding telemetry provides any actionable signals
packages/drivers/odsp-driver/src/odspDocumentDeltaConnection.ts
Outdated
Show resolved
Hide resolved
Speculative fix to prevent OdspDocumentDeltaConnection from emitting on reused sockets after disconnect.
Speculative fix to prevent OdspDocumentDeltaConnection from emitting on reused sockets after disconnect.
In #3627, we observe messages are being sent with old clientId. The default implementation of
DocumentDeltaManager.disconnect()
generally protects against this by disconnecting the socket on disconnect(). However, there's nothing actually stopping theBatchManager
from attempting to emit on the old socket if it still has messages in the queue -- it will just fail because the socket is disconnected.This is a speculative fix -- we suspect that since
OdspDocumentDeltaManager
overridesdisconnect()
to allow for socket reuse, these still-open sockets are emitting leftover messages. This change introduces a flag to more explicitly indicate/check whether emitting on the socket should be allowed.With Helio's #3704, we should have the correct telemetry in place to determine whether this is effective in eliminating the issue.