mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00:00
fix(lint): don't recurse infinitely for large ASTs (#28265)
We previously failed to lint `./cli/tsc/00_typescript.js` with plugins, because every "next" node would cause a new stack frame to be added.
This commit is contained in:
parent
f373a20a6f
commit
55dc6f4b93
1 changed files with 35 additions and 37 deletions
|
@ -1150,7 +1150,7 @@ export function runPluginsForFile(fileName, serializedAst) {
|
||||||
* @param {CancellationToken} cancellationToken
|
* @param {CancellationToken} cancellationToken
|
||||||
*/
|
*/
|
||||||
function traverse(ctx, visitors, idx, cancellationToken) {
|
function traverse(ctx, visitors, idx, cancellationToken) {
|
||||||
if (idx === AST_IDX_INVALID) return;
|
while (idx !== AST_IDX_INVALID) {
|
||||||
if (cancellationToken.isCancellationRequested()) return;
|
if (cancellationToken.isCancellationRequested()) return;
|
||||||
|
|
||||||
const { buf } = ctx;
|
const { buf } = ctx;
|
||||||
|
@ -1195,9 +1195,7 @@ function traverse(ctx, visitors, idx, cancellationToken) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const nextIdx = readNext(buf, idx);
|
idx = readNext(buf, idx);
|
||||||
if (nextIdx > AST_IDX_INVALID) {
|
|
||||||
traverse(ctx, visitors, nextIdx, cancellationToken);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue