Skip to content

Conversation

eps1lon
Copy link
Collaborator

@eps1lon eps1lon commented Sep 15, 2025

The alternative would be to make instance.suspendedBy unique on IO instead of async info:

} else if (suspendedBy.indexOf(asyncInfo) === -1) {
suspendedBy.push(asyncInfo);
}

@meta-cla meta-cla bot added the CLA Signed label Sep 15, 2025
@github-actions github-actions bot added the React Core Team Opened by a member of the React Core Team label Sep 15, 2025
@eps1lon eps1lon marked this pull request as ready for review September 15, 2025 15:45
@eps1lon eps1lon requested a review from sebmarkbage September 15, 2025 15:45
!suspendedBySet.delete(instance)
(!removedIOInfos.has(ioInfo) && !suspendedBySet.delete(instance))
) {
throw new Error(
Copy link
Collaborator

Choose a reason for hiding this comment

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

You could just check previousSuspendedBy.indexOf(asyncInfo) < i.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Instead of what? The async info in suspendedBy is unique in this case. It's the IO that's not.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see. Then you can do it one level below with a custom loop walking to this index. Still likely faster to check a small set like this in the existing array than even just running the .has(). Let alone allocating and maintaining the set.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

if (
suspendedBySet === undefined ||
!suspendedBySet.delete(instance)
(!alreadyRemovedIO && !suspendedBySet.delete(instance))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ideally we'd check if !suspendedBySet.delete(instance) first before doing the loop so that in the common case when we do succeed in deleting it, there's no reason to check.

Copy link
Collaborator

@sebmarkbage sebmarkbage left a comment

Choose a reason for hiding this comment

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

Perf optimization would be good for the common case.

@eps1lon eps1lon merged commit 851bad0 into facebook:main Sep 16, 2025
241 checks passed
@eps1lon eps1lon deleted the sebbie/09-15-_devtools_ignore_repeated_removals_of_the_same_io branch September 22, 2025 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed React Core Team Opened by a member of the React Core Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants