Don't wait on runtime confirmation when opening

Ydoc doesn't like delays so if opening a file takes a considerably more
time than usual (locking, more files to compile), ydoc will bail and
fail to initiialize properly. This is rather trivially reproducible by
adding `Thread.sleep(20*000)` to OpenFileCmd but automatic testing is
non-trivial.
This commit is contained in:
Hubert Plociniczak 2024-07-19 00:55:08 +02:00
parent 451d7cb452
commit fccb9500e1

View File

@ -179,13 +179,10 @@ class CollaborativeBuffer(
) )
} else { } else {
logger.warn("Timeout reached when awaiting response from the server") logger.warn("Timeout reached when awaiting response from the server")
replyTo ! OpenFileResponse(Left(OperationTimeout))
stop(Map.empty) stop(Map.empty)
} }
case Api.Response(Some(id), Api.OpenFileResponse) if id == requestId => case Api.Response(Some(id), Api.OpenFileResponse) if id == requestId =>
timeout.cancel() timeout.cancel()
val cap = CapabilityRegistration(CanEdit(bufferPath))
replyTo ! OpenFileResponse(Right(OpenFileResult(buffer, Some(cap))))
unstashAll() unstashAll()
context.become( context.become(
collaborativeEditing( collaborativeEditing(
@ -894,6 +891,8 @@ class CollaborativeBuffer(
self, self,
ServerConfirmationTimeout ServerConfirmationTimeout
) )
val cap = CapabilityRegistration(CanEdit(bufferPath))
replyTo ! OpenFileResponse(Right(OpenFileResult(buffer, Some(cap))))
context.become( context.become(
waitingOnServerConfirmation( waitingOnServerConfirmation(
requestId, requestId,