Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from Jun 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 0 additions & 11 deletions packages/babel-traverse/src/context.ts
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down