Commit 99d18b4
fix(feishu): gate onConfirmedConnect on readyState OPEN (P2 nonce-delay fix)
The SDK's reconnect nonce delay can be up to 30 s. During this window
`lastConnectTime` is already non-zero (set by the failed initial attempt)
and stable, so FEISHU_WS_STABLE_TICKS_REQUIRED (2 ticks ≈ 20 s) is reached
before the nonce expires. This triggered `onConfirmedConnect` falsely, setting
`hadSuccessfulConnect = true` even though no connection was established —
causing boot-time failures to reset `supervisorAttempt` to 0 and preventing
exponential backoff escalation.
Fix: gate `onConfirmedConnect` on the same `getWsReadyState()` check added in
the previous commit. If `readyState === 1` (OPEN) or is not observable (null,
for tests/future SDK changes — backward-compatible fallback), fire the callback.
If readyState is known but not OPEN (e.g. 0=CONNECTING during nonce wait),
defer confirmation until the socket is actually open.
`getWsReadyState()` is extracted as a shared helper used by both the
confirmed-connect path and the post-reconnect stall-clock clear path.
Regression test added: "does not confirm connection during nonce delay" —
verifies that readyState CONNECTING blocks onConfirmedConnect and allows
supervisorAttempt to increment on subsequent stall.
Addresses Codex P2 in #57978 (2026-04-06 review comment on
line 267 of monitor.transport.ts).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent b05a832 commit 99d18b4
2 files changed
Lines changed: 112 additions & 31 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
324 | 324 | | |
325 | 325 | | |
326 | 326 | | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
327 | 392 | | |
328 | 393 | | |
329 | 394 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
201 | 201 | | |
202 | 202 | | |
203 | 203 | | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
204 | 218 | | |
205 | 219 | | |
206 | 220 | | |
| |||
257 | 271 | | |
258 | 272 | | |
259 | 273 | | |
260 | | - | |
261 | | - | |
262 | | - | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
263 | 283 | | |
264 | 284 | | |
265 | 285 | | |
266 | | - | |
267 | | - | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
268 | 293 | | |
269 | 294 | | |
270 | 295 | | |
| |||
274 | 299 | | |
275 | 300 | | |
276 | 301 | | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
281 | 306 | | |
282 | 307 | | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
289 | 311 | | |
290 | 312 | | |
291 | 313 | | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
308 | 323 | | |
| 324 | + | |
309 | 325 | | |
310 | 326 | | |
311 | 327 | | |
| |||
0 commit comments