1
+ /* eslint-disable @typescript-eslint/no-non-null-assertion */
2
+
1
3
import WorkerPoolFunction from './WorkerPoolFunction.js'
2
4
import WorkerPoolProgressCallback from './WorkerPoolProgressCallback.js'
3
5
import WorkerPoolRunTasksResult from './WorkerPoolRunTasksResult.js'
@@ -104,9 +106,8 @@ class WorkerPool {
104
106
const info = this . runInfo [ infoIndex ]
105
107
106
108
if ( info ?. canceled === true ) {
109
+ info . reject ! ( 'Remaining tasks canceled' )
107
110
this . clearTask ( info . index )
108
- // @ts -expect-error: error TS2722: Cannot invoke an object which is
109
- info ?. reject ( 'Remaining tasks canceled' )
110
111
return
111
112
}
112
113
@@ -129,17 +130,13 @@ class WorkerPool {
129
130
this . addTask ( infoIndex , reTask [ 0 ] , reTask [ 1 ] )
130
131
} else if ( ! info . addingTasks && info . runningWorkers === 0 ) {
131
132
const results = info . results
133
+ info . resolve ! ( results )
132
134
this . clearTask ( info . index )
133
- // @ts -expect-error: error TS2722: Cannot invoke an object which is
134
- // possibly 'undefined'.
135
- info ?. resolve ( results )
136
135
}
137
136
}
138
137
} ) . catch ( ( error ) => {
138
+ info . reject ! ( error )
139
139
this . clearTask ( info . index )
140
- // @ts -expect-error: error TS2722: Cannot invoke an object which is
141
- // possibly 'undefined'.
142
- info ?. reject ( error )
143
140
} )
144
141
} else {
145
142
if ( info . runningWorkers !== 0 || info . postponed ) {
@@ -162,6 +159,8 @@ class WorkerPool {
162
159
this . runInfo [ clearIndex ] . taskQueue = [ ]
163
160
this . runInfo [ clearIndex ] . progressCallback = null
164
161
this . runInfo [ clearIndex ] . canceled = null
162
+ this . runInfo [ clearIndex ] . reject = ( ) => { }
163
+ this . runInfo [ clearIndex ] . resolve = ( ) => { }
165
164
}
166
165
}
167
166
0 commit comments