Commit ee33e31
committed
Fix mixed undefined/Promise values in Promise.all in updates.ts
This commit fixes incorrect usage of Promise.all() where the mapped
array could contain undefined values mixed with Promises, causing
ESLint errors.
Problem:
The downloadDatabaseUpdateFromGitHub function was passing an array to
Promise.all() where map callbacks could return either:
- undefined (when no update is found for a database)
- A Promise<void> (from the withProgress call)
ESLint rule '@typescript-eslint/await-thenable' detected this error at
line 172: 'Unexpected iterable of non-Promise (non-"Thenable") values
passed to promise aggregator'
The code pattern was:
await Promise.all(
selectedDatabases.map((database) => {
const update = updates.find(...);
return; // ❌ returns undefined
}
return withProgress(...); // ✓ returns Promise
})
);
This creates an array like [Promise, undefined, Promise, undefined]
which violates Promise.all()'s type contract expecting all Promises.
Solution:
1. Change early return from 'return;' to 'return undefined;' for
explicit clarity
2. Filter out undefined values before passing to Promise.all() using a
type guard:
.filter((p): p is Promise<void> => p !== undefined)
This ensures Promise.all() receives only actual Promise objects while
maintaining the same runtime behavior (skipping databases without
updates).
File modified:
- extensions/ql-vscode/src/databases/github-databases/updates.ts1 parent 8793d0b commit ee33e31
File tree
1 file changed
+40
-38
lines changed- extensions/ql-vscode/src/databases/github-databases
1 file changed
+40
-38
lines changedLines changed: 40 additions & 38 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
177 | 178 | | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
192 | 205 | | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
202 | 209 | | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
213 | 215 | | |
214 | 216 | | |
0 commit comments