Skip to content

Avoid infinite recursion in resolveSource#256

Merged
nicolo-ribaudo merged 2 commits intobabel:mainfrom
nicolo-ribaudo:infinite-loop-regression
Mar 16, 2026
Merged

Avoid infinite recursion in resolveSource#256
nicolo-ribaudo merged 2 commits intobabel:mainfrom
nicolo-ribaudo:infinite-loop-regression

Conversation

@nicolo-ribaudo
Copy link
Copy Markdown
Member

@nicolo-ribaudo nicolo-ribaudo commented Mar 16, 2026

resolveSource calls itself on the result of resolve() on its path. resolve can return an ancestor (if the variable references itself in its initializer), causing an infinite loop.

Adding a seen list fixes it.

Fixes #254

@nicolo-ribaudo nicolo-ribaudo changed the title Add test for issue 254 Avoid infinite recursion in resolveSource Mar 16, 2026
@nicolo-ribaudo nicolo-ribaudo marked this pull request as ready for review March 16, 2026 20:53
@nicolo-ribaudo nicolo-ribaudo merged commit bac4f17 into babel:main Mar 16, 2026
6 checks passed
@nicolo-ribaudo nicolo-ribaudo deleted the infinite-loop-regression branch April 10, 2026 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Maximum call stack size exceeded in resolveSource when using @babel/helper-define-polyfill-provider 0.6.7 with @vitejs/plugin-legacy

1 participant