@@ -2053,7 +2053,7 @@ function commitRootImpl(root, renderPriorityLevel) {
2053
2053
hasUncaughtError = false ;
2054
2054
const error = firstUncaughtError ;
2055
2055
firstUncaughtError = null ;
2056
- // TODO: how to handle cache cleanup here?
2056
+ releaseRootPooledCache ( root ) ;
2057
2057
throw error ;
2058
2058
}
2059
2059
@@ -2096,13 +2096,7 @@ function commitRootImpl(root, renderPriorityLevel) {
2096
2096
2097
2097
// Now that effects have run - giving Cache boundaries a chance to retain the
2098
2098
// cache instance - release the root's cache in case since the render is complete
2099
- if ( enableCache ) {
2100
- const pooledCache = root . pooledCache ;
2101
- if ( pooledCache != null ) {
2102
- releaseCache ( pooledCache ) ;
2103
- root . pooledCache = null ;
2104
- }
2105
- }
2099
+ releaseRootPooledCache ( root ) ;
2106
2100
2107
2101
if ( __DEV__ ) {
2108
2102
if ( enableDebugTracing ) {
@@ -2117,6 +2111,16 @@ function commitRootImpl(root, renderPriorityLevel) {
2117
2111
return null ;
2118
2112
}
2119
2113
2114
+ function releaseRootPooledCache ( root ) {
2115
+ if ( enableCache ) {
2116
+ const pooledCache = root . pooledCache ;
2117
+ if ( pooledCache != null ) {
2118
+ releaseCache ( pooledCache ) ;
2119
+ root . pooledCache = null ;
2120
+ }
2121
+ }
2122
+ }
2123
+
2120
2124
export function flushPassiveEffects ( ) : boolean {
2121
2125
// Returns whether passive effects were flushed.
2122
2126
// TODO: Combine this check with the one in flushPassiveEFfectsImpl. We should
0 commit comments