WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@nathannewyen
Copy link

Add cycle detection to prevent infinite loops when traversing the each block's linked list during reconciliation.

Fixes #17368

Add cycle detection to prevent infinite loops in the each block's linked
list traversal during reconciliation. If a cycle is detected in the
linked list (where a node's `next` pointer references an already-visited
node), the loop breaks early to prevent the `to_destroy` array from
growing indefinitely and causing a RangeError.

In development mode, a warning is logged to help with debugging when a
cycle is detected.

Fixes sveltejs#17368
@changeset-bot
Copy link

changeset-bot bot commented Dec 20, 2025

⚠️ No Changeset found

Latest commit: 8206915

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@Rich-Harris
Copy link
Member

Thank you but this isn't really a solution — it hides the bug rather than fixing it, and adds significant extra work (checking visited) to a hot code path. It also doesn't have a regression test, so there's nothing to prevent the issue happening again. As such, I'll close this — we really need a repro on the original issue before we can tackle it.

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.

RangeError: Invalid array length triggered from each block internal code

2 participants