mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-23 22:11:38 +00:00
Enhance session management and UI state handling
- Added checks to handle session disconnections during confirmation in ServeSession, preventing further actions on a disconnected session. - Updated App:startSession to manage UI state in one-shot sync mode, ensuring a loading state is displayed instead of a connected page. - Implemented safety measures in App:endSession to reset UI state if the session reference is cleared, addressing potential race conditions.
This commit is contained in:
parent
a81096c01d
commit
0e263789b0
2 changed files with 58 additions and 9 deletions
|
|
@ -278,6 +278,12 @@ function ServeSession:__onWebSocketMessage(messagesPacket)
|
|||
self.__confirmingPatch = nil
|
||||
self.__isConfirming = false
|
||||
|
||||
-- If the session was disconnected during the confirmation yield
|
||||
-- (e.g., WebSocket error, server crash), bail out immediately.
|
||||
if self.__status == Status.Disconnected then
|
||||
return
|
||||
end
|
||||
|
||||
-- Resume ChangeBatcher after confirmation
|
||||
self.__changeBatcher:resume()
|
||||
|
||||
|
|
@ -656,6 +662,13 @@ function ServeSession:__confirmAndApplyInitialPatch(catchUpPatch, serverInfo)
|
|||
self.__confirmingPatch = nil
|
||||
self.__isConfirming = false
|
||||
|
||||
-- If the session was disconnected during the confirmation yield
|
||||
-- (e.g., WebSocket error, server crash), bail out immediately.
|
||||
-- Don't resume batcher or apply patches on a dead session.
|
||||
if self.__status == Status.Disconnected then
|
||||
return Promise.reject("Session disconnected during confirmation")
|
||||
end
|
||||
|
||||
-- Resume ChangeBatcher after confirmation
|
||||
self.__changeBatcher:resume()
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue