Repository navigation
Commit 2143789
committed
fix(McpHub): register the oauth watcher before installing the cancellation callback
The previous TDZ fix made cancellationDisposable safe under
synchronous callback firing, but the _oauthWatchers.set(watcherKey, ...)
call after the onCancellationRequested(...) registration is still
racy. If the token is already cancelled at registration time and
the callback fires synchronously, cleanup() runs (which tries to
_oauthWatchers.delete the entry) before the entry has been added,
leaving an orphan watcher in the map after the flow has otherwise
torn itself down.
Moved the watcher registration above the onCancellationRequested
call so the entry exists in the map before the callback can fire.
A sync-firing cleanup() now finds and deletes it cleanly. Extended
the existing already-cancelled-token regression test to assert
_oauthWatchers is empty after the flow resolves.1 parent efc8678 commit 2143789
2 files changed
Lines changed: 17 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1186 | 1186 | | |
1187 | 1187 | | |
1188 | 1188 | | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
1189 | 1197 | | |
1190 | 1198 | | |
1191 | 1199 | | |
| |||
1207 | 1215 | | |
1208 | 1216 | | |
1209 | 1217 | | |
1210 | | - | |
1211 | | - | |
1212 | | - | |
1213 | 1218 | | |
1214 | 1219 | | |
1215 | 1220 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2618 | 2618 | | |
2619 | 2619 | | |
2620 | 2620 | | |
| 2621 | + | |
| 2622 | + | |
| 2623 | + | |
| 2624 | + | |
| 2625 | + | |
| 2626 | + | |
| 2627 | + | |
| 2628 | + | |
| 2629 | + | |
2621 | 2630 | | |
2622 | 2631 | | |
2623 | 2632 | | |
| |||
0 commit comments