Repository navigation
Commit 0219d1a
easonLiangWorldedtech
fix(webview): stop touching a provider that has begun disposal
The Lifecycle Resource Cleanup row at head 420c995: the cross-view profile
mutation path could do work on a provider that was already being torn down.
dispose() set _disposed on its first line but only unregistered the instance from
activeInstances after every awaited teardown step - task eviction plus six
guarded manager cleanups. For that whole window the provider was already
_disposed and yet still enumerable through getAllInstances(),
getVisibleInstance() and getInstanceForView(), so a sibling profile upsert or
deletion could persist durable view state and post to a webview that is gone.
1. dispose() now unregisters the instance synchronously at the start of disposal,
before its first await, and the stale comment about the unregistration running
"below" is corrected. No teardown step looks this instance up in the registry,
so moving it costs nothing and closes the window completely.
2. refreshViewLocalStateForUpdatedProfile and rePinViewLocalStateForDeletedProfile
exclude instances that have begun disposal from the affected set, and re-check
the flag before each sibling persistence, post, and compensating restore. The
affected set is enumerated before any await, so a sibling can start disposing
after the enumeration and before each of those operations.
Skipping a disposing sibling is safe rather than lossy: viewId comes from the
monotonic nextViewId counter, so that view's viewStates entry is orphaned the
moment it begins disposal - no future view reads that key again, and
prunePersistedViewStates() bounds the map.
Five tests, each with a negative control reverted byte-for-byte:
- dispose unregisters before the awaited cleanup finishes (gate held open on the
last teardown step); moving the unregistration back turns exactly this red.
- refresh reaches a live sibling but not one that has begun disposal; removing the
enumeration filter together with the loop's first re-check turns exactly this
red. The filter alone is an equivalent mutant - the loop's first re-check tests
the same predicate with no await in between, so it subsumes the filter.
- refresh does not post to a sibling that starts disposing mid-flight; removing
the post guard turns exactly this red.
- the deletion re-pins a live sibling but not a disposing one; same equivalence
note as above for the filter.
- the re-pin skips both the post and the compensating restore for a sibling that
starts disposing mid-flight; each of those two guards on its own turns this red.
Verification: ClineProvider.spec.ts 303 passed, core/webview 756 passed,
core/config 254 passed, activate 112 passed; full eslint . --ext=ts
--max-warnings=0 exit 0; tsc --noEmit 0 errors under the local tsconfig paths
override; eslint suppressions unchanged (prune: 0 semantic diffs).
Two recorded observations, neither caused by this commit and neither worth a
production change: EnvironmentTeardownError "Closing rpc while onUserConsoleLog
was pending" is a HEAD-baseline flake in this spec - the unmodified HEAD spec
threw it in 2 of 3 runs (16, 13, 0 unhandled) against 2 of 3 for this file
(0, 1, 6), with every test passing in all six runs. DEFAULT_WRITE_DELAY_MS reds
in the misc suite are a node_modules junction artifact resolved by aliasing
@roo-code/types to this worktree's packages/types/src.1 parent 420c995 commit 0219d1a
2 files changed
Lines changed: 363 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1159 | 1159 | | |
1160 | 1160 | | |
1161 | 1161 | | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
1162 | 1169 | | |
1163 | 1170 | | |
1164 | 1171 | | |
| |||
1207 | 1214 | | |
1208 | 1215 | | |
1209 | 1216 | | |
1210 | | - | |
1211 | | - | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
1212 | 1220 | | |
1213 | 1221 | | |
1214 | 1222 | | |
| |||
1238 | 1246 | | |
1239 | 1247 | | |
1240 | 1248 | | |
1241 | | - | |
1242 | | - | |
1243 | 1249 | | |
1244 | 1250 | | |
1245 | 1251 | | |
| |||
2911 | 2917 | | |
2912 | 2918 | | |
2913 | 2919 | | |
2914 | | - | |
| 2920 | + | |
| 2921 | + | |
| 2922 | + | |
2915 | 2923 | | |
2916 | 2924 | | |
2917 | 2925 | | |
| |||
2920 | 2928 | | |
2921 | 2929 | | |
2922 | 2930 | | |
| 2931 | + | |
| 2932 | + | |
| 2933 | + | |
| 2934 | + | |
| 2935 | + | |
| 2936 | + | |
| 2937 | + | |
| 2938 | + | |
| 2939 | + | |
| 2940 | + | |
2923 | 2941 | | |
2924 | 2942 | | |
| 2943 | + | |
| 2944 | + | |
| 2945 | + | |
2925 | 2946 | | |
2926 | 2947 | | |
2927 | 2948 | | |
| |||
2940 | 2961 | | |
2941 | 2962 | | |
2942 | 2963 | | |
2943 | | - | |
| 2964 | + | |
| 2965 | + | |
| 2966 | + | |
| 2967 | + | |
2944 | 2968 | | |
2945 | 2969 | | |
2946 | 2970 | | |
| |||
2966 | 2990 | | |
2967 | 2991 | | |
2968 | 2992 | | |
| 2993 | + | |
| 2994 | + | |
| 2995 | + | |
| 2996 | + | |
| 2997 | + | |
| 2998 | + | |
| 2999 | + | |
| 3000 | + | |
| 3001 | + | |
| 3002 | + | |
2969 | 3003 | | |
2970 | 3004 | | |
| 3005 | + | |
| 3006 | + | |
| 3007 | + | |
2971 | 3008 | | |
2972 | 3009 | | |
2973 | 3010 | | |
| |||
2981 | 3018 | | |
2982 | 3019 | | |
2983 | 3020 | | |
| 3021 | + | |
| 3022 | + | |
| 3023 | + | |
| 3024 | + | |
| 3025 | + | |
| 3026 | + | |
| 3027 | + | |
| 3028 | + | |
2984 | 3029 | | |
2985 | 3030 | | |
2986 | 3031 | | |
| |||
0 commit comments