* Resolve one batch with a yield checkpoint between EVERY ref so the #850 * liveness heartbeat can fire on a slow/dense batch (#1091). The checkpoint * granularity is per-ref — not per-N-refs — because per-ref cost is unbounded * in the worst case (a collision-heavy method name whose candid
(
batch: UnresolvedReference[],
maybeYield: MaybeYield
)
| 1321 | * between refs changes only timing, never which edges get created. |
| 1322 | */ |
| 1323 | private async resolveBatchYielding( |
| 1324 | batch: UnresolvedReference[], |
| 1325 | maybeYield: MaybeYield |
| 1326 | ): Promise<ResolutionResult> { |
| 1327 | this.warmCaches(); |
| 1328 | this.advanceSupertypeGeneration(); |
| 1329 | |
| 1330 | const resolved: ResolvedRef[] = []; |
| 1331 | const unresolved: UnresolvedRef[] = []; |
| 1332 | const byMethod: Record<string, number> = {}; |
| 1333 | |
| 1334 | for (const raw of batch) { |
| 1335 | const ref: UnresolvedRef = { |
| 1336 | fromNodeId: raw.fromNodeId, |
| 1337 | referenceName: raw.referenceName, |
| 1338 | referenceKind: raw.referenceKind, |
| 1339 | line: raw.line, |
| 1340 | column: raw.column, |
| 1341 | filePath: raw.filePath || this.getFilePathFromNodeId(raw.fromNodeId), |
| 1342 | language: raw.language || this.getLanguageFromNodeId(raw.fromNodeId), |
| 1343 | rowId: raw.rowId, |
| 1344 | }; |
| 1345 | const result = this.resolveOneTimed(ref); |
| 1346 | if (result) { |
| 1347 | resolved.push(result); |
| 1348 | byMethod[result.resolvedBy] = (byMethod[result.resolvedBy] || 0) + 1; |
| 1349 | } else { |
| 1350 | unresolved.push(ref); |
| 1351 | } |
| 1352 | // Fast-path the per-ref yield check: awaiting the async no-op costs a |
| 1353 | // microtask hop per ref, which dominates at ~10⁵ refs (see MaybeYield). |
| 1354 | const y = maybeYield(); |
| 1355 | if (y) await y; |
| 1356 | } |
| 1357 | |
| 1358 | return { |
| 1359 | resolved, |
| 1360 | unresolved, |
| 1361 | stats: { |
| 1362 | total: batch.length, |
| 1363 | resolved: resolved.length, |
| 1364 | unresolved: unresolved.length, |
| 1365 | byMethod, |
| 1366 | }, |
| 1367 | }; |
| 1368 | } |
| 1369 | |
| 1370 | /** |
| 1371 | * Resolve a list of refs and return everything the ADMISSION side needs to |
no test coverage detected