Refactor: Fix Event Buffer Deadlock with State Machine (#1633)
* feat: implement state machine for chat synchronization and buffer management * test: Add Jest configuration and tests for connection deadlock handling - Created a Jest configuration file to set up testing environment. - Implemented utility functions for creating isolated authentication sessions and mocking WebSocket connections. - Added a test case to ensure that the connection does not deadlock when history sync is disabled, verifying the correct handling of message events. * feat: add GitHub Actions workflow for running tests * chore: sort import lint * fix: implement timeout handling for AwaitingInitialSync state in chat socket, maybe fix memory leak * feat: enhance chat synchronization by refining AwaitingInitialSync handling and adding history sync checks
This commit is contained in:
committed by
GitHub
parent
1a721bb242
commit
812e53e4eb
+12
-3
@@ -3,10 +3,19 @@ import type { UserFacingSocketConfig } from '../Types'
|
||||
import { makeCommunitiesSocket } from './communities'
|
||||
|
||||
// export the last socket layer
|
||||
const makeWASocket = (config: UserFacingSocketConfig) =>
|
||||
makeCommunitiesSocket({
|
||||
const makeWASocket = (config: UserFacingSocketConfig) => {
|
||||
const newConfig = {
|
||||
...DEFAULT_CONNECTION_CONFIG,
|
||||
...config
|
||||
})
|
||||
}
|
||||
|
||||
// If the user hasn't provided their own history sync function,
|
||||
// let's create a default one that respects the syncFullHistory flag.
|
||||
if (config.shouldSyncHistoryMessage === undefined) {
|
||||
newConfig.shouldSyncHistoryMessage = () => !!newConfig.syncFullHistory
|
||||
}
|
||||
|
||||
return makeCommunitiesSocket(newConfig)
|
||||
}
|
||||
|
||||
export default makeWASocket
|
||||
|
||||
Reference in New Issue
Block a user