X Tutup
Skip to content

Fix traverse NodePath caching#17568

Merged
nicolo-ribaudo merged 4 commits intobabel:mainfrom
coderaiser:fix/traverse-no-parent-path
Oct 29, 2025
Merged

Fix traverse NodePath caching#17568
nicolo-ribaudo merged 4 commits intobabel:mainfrom
coderaiser:fix/traverse-no-parent-path

Conversation

@coderaiser
Copy link
Contributor

@coderaiser coderaiser commented Oct 24, 2025

Q                       A
Fixed Issues? Fixes #17567, Fixes #17563
Patch: Bug Fix? Yes
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

@babel-bot
Copy link
Collaborator

babel-bot commented Oct 24, 2025

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/60125

@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 24, 2025

Open in StackBlitz

commit: 2a21c37

@nicolo-ribaudo nicolo-ribaudo added i: regression PR: Bug Fix (next major) 🐛 A type of pull request used for our changelog categories for next major release labels Oct 24, 2025
@liuxingbaoyu
Copy link
Member

Thanks!
The issue comes from here,

if (!process.env.BABEL_8_BREAKING && this.opts?.noScope) return;
, but I forgot why I did that.

@coderaiser coderaiser force-pushed the fix/traverse-no-parent-path branch from be8e6b8 to 9d9779b Compare October 24, 2025 15:39
@liuxingbaoyu
Copy link
Member

We can just revert the change in

if (!process.env.BABEL_8_BREAKING && this.opts?.noScope) return;
and it seems the tests still pass.

@coderaiser
Copy link
Contributor Author

@liuxingbaoyu should I just remove this line instead of checking path?

@liuxingbaoyu
Copy link
Member

Removing the !process.env.BABEL_8_BREAKING check should fix this regression.
This was added in #17043.
But please don't merge it yet; I'll try again later to see if there are any other issues.

@coderaiser
Copy link
Contributor Author

@liuxingbaoyu as I see only removing check for !process.env.BABEL_8_BREAKING makes test fail, we also pass BABEL_8_BREAKING to run the test:

make build && BABEL_8_BREAKING=true yarn jest babel-traverse

So with this line or without, additional check for path is still neaded.

@JLHwung
Copy link
Contributor

JLHwung commented Oct 26, 2025

Pending @liuxingbaoyu's investigation result.

@liuxingbaoyu
Copy link
Member

Well, forceSetScope is back. 🤦‍♂️
This is a bit complicated. I'll try to explain it.

I added forceSetScope or !process.env.BABEL_8_BREAKING && because noScope polluted the cache.
Later, we stopped using noScope in traverse.hasType, and the issue in tests no longer appeared.
The issue reappeared in #17563.

The fix we made in this PR conflicts with #17565, preventing it from fixing #17563.
So I merged them into this PR.

Copy link
Member

@nicolo-ribaudo nicolo-ribaudo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:/

@nicolo-ribaudo nicolo-ribaudo changed the title fix: babel-traverse: no parent path Fix traverse NodePath caching Oct 29, 2025
@nicolo-ribaudo nicolo-ribaudo merged commit d1e1bad into babel:main Oct 29, 2025
74 checks passed
@coderaiser coderaiser deleted the fix/traverse-no-parent-path branch October 30, 2025 05:54
coderaiser added a commit to putoutjs/babel that referenced this pull request Nov 11, 2025
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Jan 30, 2026
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

i: regression outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Bug Fix (next major) 🐛 A type of pull request used for our changelog categories for next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Babel 8 Beta 3: TypeError: Cannot read properties of null (reading 'isMethod') Strange cache in Babel 8 Beta 3

5 participants

X Tutup