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 double unmount #4105

Merged
merged 2 commits into from
Aug 19, 2023
Merged

Fix double unmount #4105

merged 2 commits into from
Aug 19, 2023

Conversation

developit
Copy link
Member

@developit developit commented Aug 18, 2023

This should fix #4104.

I believe the issue is that unmount() is triggered for the VNode at oldChildren[i], but that VNode remains in oldChildren. When we hit the end of diffChildren(), a loop invokes unmount() on every non-null vnode in oldChildren, which still includes the eagerly-unmounted VNode.

I didn't have a chance to add a test as I'm doing this from GH web, if someone gets around to it before me we can likely just use the example from #4104.

This should fix #4104.
@github-actions
Copy link

github-actions bot commented Aug 18, 2023

📊 Tachometer Benchmark Results

Summary

A summary of the benchmark results will show here once they finish.

Results

The full results of your benchmarks will show here once they finish.

tachometer-reporter-action v2 for Benchmarks

@github-actions
Copy link

github-actions bot commented Aug 18, 2023

Size Change: +8 B (0%)

Total Size: 57.3 kB

Filename Size Change
dist/preact.js 4.36 kB +1 B
dist/preact.min.js 4.4 kB +2 B (0%)
dist/preact.min.module.js 4.4 kB +2 B (0%)
dist/preact.min.umd.js 4.42 kB +1 B
dist/preact.module.js 4.39 kB +1 B
dist/preact.umd.js 4.43 kB +1 B
ℹ️ View Unchanged
Filename Size Change
compat/dist/compat.js 3.95 kB 0 B
compat/dist/compat.module.js 3.87 kB 0 B
compat/dist/compat.umd.js 4.01 kB 0 B
debug/dist/debug.js 3.64 kB 0 B
debug/dist/debug.module.js 3.62 kB 0 B
debug/dist/debug.umd.js 3.71 kB 0 B
devtools/dist/devtools.js 232 B 0 B
devtools/dist/devtools.module.js 240 B 0 B
devtools/dist/devtools.umd.js 315 B 0 B
hooks/dist/hooks.js 1.53 kB 0 B
hooks/dist/hooks.module.js 1.56 kB 0 B
hooks/dist/hooks.umd.js 1.62 kB 0 B
jsx-runtime/dist/jsxRuntime.js 360 B 0 B
jsx-runtime/dist/jsxRuntime.module.js 326 B 0 B
jsx-runtime/dist/jsxRuntime.umd.js 441 B 0 B
test-utils/dist/testUtils.js 453 B 0 B
test-utils/dist/testUtils.module.js 454 B 0 B
test-utils/dist/testUtils.umd.js 536 B 0 B

compressed-size-action

@coveralls
Copy link

coveralls commented Aug 18, 2023

Coverage Status

coverage: 99.563%. remained the same when pulling b4dc892 on bugfix/double-unmount into 2e89591 on main.

Copy link
Member

@andrewiggins andrewiggins left a comment

Choose a reason for hiding this comment

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

Added a test.

Something fun I noticed: You can't observe this bug using lifecycles cuz on the first unmount, we clear _component which prevents re-entry into the part of unmount that invokes componentWillUnmount.

Copy link
Member

@marvinhagemeister marvinhagemeister left a comment

Choose a reason for hiding this comment

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

Nice catch 👍

@JoviDeCroock JoviDeCroock merged commit 85ab2c6 into main Aug 19, 2023
12 checks passed
@JoviDeCroock JoviDeCroock deleted the bugfix/double-unmount branch August 19, 2023 07:00
@JoviDeCroock JoviDeCroock mentioned this pull request Aug 19, 2023
@JoviDeCroock JoviDeCroock mentioned this pull request Apr 27, 2024
13 tasks
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.

Unbalanced number of mount/unmount calls for a child node when the node is added and removed
5 participants