fix: remove traverse trap on NODE_ENV == "test" (#13475)

This commit is contained in:
Huáng Jùnliàng 2021-06-17 10:29:56 -04:00 committed by GitHub
parent d74838609e
commit dddb4133d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,8 +2,6 @@ import NodePath from "./path";
import * as t from "@babel/types";
import type Scope from "./scope";
const testing = process.env.NODE_ENV === "test";
export default class TraversalContext {
constructor(scope, opts, state, parentPath) {
this.parentPath = parentPath;
@ -18,7 +16,6 @@ export default class TraversalContext {
declare opts;
queue: Array<NodePath> | null = null;
priorityQueue: Array<NodePath> | null = null;
declare trap?: boolean;
/**
* This method does a simple check to determine whether or not we really need to attempt
@ -57,10 +54,6 @@ export default class TraversalContext {
}
maybeQueue(path, notPriority?: boolean) {
if (this.trap) {
throw new Error("Infinite cycle detected");
}
if (this.queue) {
if (notPriority) {
this.queue.push(path);
@ -120,10 +113,6 @@ export default class TraversalContext {
// this path no longer belongs to the tree
if (path.key === null) continue;
if (testing && queue.length >= 10_000) {
this.trap = true;
}
// ensure we don't visit the same node twice
const { node } = path;
if (visited.has(node)) continue;