File tree Expand file tree Collapse file tree 1 file changed +12
-14
lines changed Expand file tree Collapse file tree 1 file changed +12
-14
lines changed Original file line number Diff line number Diff line change @@ -664,22 +664,27 @@ suite('Kernel Connection Helpers', () => {
664664 function createMockKernel ( options : MockKernelOptions ) {
665665 return {
666666 requestExecute : ( ) => {
667- let iopubCallback : ( ( msg : any ) => void ) | undefined ;
667+ let resolvePromise : ( value : any ) => void ;
668668
669- // Create a promise that resolves after IOPub messages are dispatched
669+ // Create a promise that will be resolved after IOPub messages are dispatched
670670 const donePromise = new Promise < any > ( ( resolve ) => {
671- // Dispatch messages asynchronously to preserve async behavior
672- setTimeout ( ( ) => {
673- if ( iopubCallback && options . messages && options . messages . length > 0 ) {
671+ resolvePromise = resolve ;
672+ } ) ;
673+
674+ return {
675+ done : donePromise ,
676+ set onIOPub ( cb : ( msg : any ) => void ) {
677+ // Invoke IOPub callback synchronously with all messages
678+ if ( options . messages && options . messages . length > 0 ) {
674679 options . messages . forEach ( ( msg ) => {
675- iopubCallback ! ( {
680+ cb ( {
676681 header : { msg_type : msg . msg_type } ,
677682 content : msg . content
678683 } ) ;
679684 } ) ;
680685 }
681686 // Resolve the done promise after messages are dispatched
682- resolve ( {
687+ resolvePromise ( {
683688 content :
684689 options . status === 'ok'
685690 ? { status : 'ok' as const }
@@ -688,13 +693,6 @@ suite('Kernel Connection Helpers', () => {
688693 ...options . errorContent
689694 }
690695 } ) ;
691- } , 0 ) ;
692- } ) ;
693-
694- return {
695- done : donePromise ,
696- set onIOPub ( cb : ( msg : any ) => void ) {
697- iopubCallback = cb ;
698696 }
699697 } ;
700698 }
You can’t perform that action at this time.
0 commit comments