@@ -648,7 +648,35 @@ describe('ParseLiveQueryServer', function () {
648648 expect ( spy . calls . count ( ) ) . toBe ( 2 ) ;
649649 } ) ;
650650
651- // TODO: Test server can set disconnect command message handler for a parseWebSocket
651+ it ( 'does not delete subscription info on client disconnect' , async ( ) => {
652+ const parseLiveQueryServer = new ParseLiveQueryServer ( { } ) ;
653+ // Add mock client and subscription
654+ const clientId = 1 ;
655+ const client = addMockClient ( parseLiveQueryServer , clientId ) ;
656+ const requestId = 2 ;
657+ const EventEmitter = require ( 'events' ) ;
658+ const parseWebSocket = new EventEmitter ( ) ;
659+ parseWebSocket . clientId = clientId ;
660+ await addMockSubscription ( parseLiveQueryServer , clientId , requestId , parseWebSocket ) ;
661+
662+ // Register message handlers (sets up disconnect handler)
663+ parseLiveQueryServer . _onConnect ( parseWebSocket ) ;
664+
665+ // Verify client exists before disconnect
666+ expect ( parseLiveQueryServer . clients . has ( clientId ) ) . toBeTrue ( ) ;
667+
668+ // Trigger disconnect
669+ parseWebSocket . emit ( 'disconnect' ) ;
670+
671+ // Prove disconnect handler executed: client removed from server
672+ expect ( parseLiveQueryServer . clients . has ( clientId ) ) . toBeFalse ( ) ;
673+
674+ // The disconnect handler must NOT call deleteSubscriptionInfo;
675+ // only the explicit unsubscribe handler does.
676+ // The advisory GHSA-3rpv-5775-m86r claims subscriptionInfo
677+ // becomes undefined on disconnect, but it does not.
678+ expect ( client . deleteSubscriptionInfo ) . not . toHaveBeenCalled ( ) ;
679+ } ) ;
652680
653681 it ( 'has no subscription and can handle object delete command' , function ( ) {
654682 const parseLiveQueryServer = new ParseLiveQueryServer ( { } ) ;
0 commit comments