File tree Expand file tree Collapse file tree 2 files changed +34
-3
lines changed
src/execution/incremental Expand file tree Collapse file tree 2 files changed +34
-3
lines changed Original file line number Diff line number Diff line change @@ -121,12 +121,9 @@ export class Queue<T> {
121121 }
122122 } catch ( error ) {
123123 const stopped = this . _stop ( error ) ;
124- /* c8 ignore start */
125- // TODO: add coverage
126124 if ( isPromise ( stopped ) ) {
127125 stopped . catch ( ( ) => undefined ) ;
128126 }
129- /* c8 ignore stop */
130127 }
131128 }
132129
Original file line number Diff line number Diff line change @@ -396,6 +396,40 @@ describe('Queue', () => {
396396 await expectPromise ( sub . next ( ) ) . toRejectWith ( 'Oops' ) ;
397397 } ) ;
398398
399+ it ( 'waits for async onStop cleanup after sync executor error' , async ( ) => {
400+ const { promise : cleanup , resolve : resolveCleanup } =
401+ // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
402+ promiseWithResolvers < void > ( ) ;
403+ let cleanupCalled = false ;
404+ const sub = new Queue ( ( { onStop } ) => {
405+ onStop ( ( ) => {
406+ cleanupCalled = true ;
407+ return cleanup ;
408+ } ) ;
409+ throw new Error ( 'Oops' ) ;
410+ } ) . subscribe ( ) ;
411+
412+ const nextPromise = sub . next ( ) ;
413+ let nextSettled = false ;
414+ nextPromise . then (
415+ ( ) => {
416+ nextSettled = true ;
417+ } ,
418+ ( ) => {
419+ nextSettled = true ;
420+ } ,
421+ ) ;
422+
423+ await resolveOnNextTick ( ) ;
424+ expect ( cleanupCalled ) . to . equal ( true ) ;
425+ expect ( nextSettled ) . to . equal ( false ) ;
426+
427+ resolveCleanup ( ) ;
428+
429+ await expectPromise ( nextPromise ) . toRejectWith ( 'Oops' ) ;
430+ expect ( nextSettled ) . to . equal ( true ) ;
431+ } ) ;
432+
399433 it ( 'delivers queued items before rejecting on async executor error' , async ( ) => {
400434 const sub = new Queue ( async ( { push } ) => {
401435 push ( 1 ) ;
You can’t perform that action at this time.
0 commit comments