-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit 670c624
fix(core): Fix client hook edge cases around multiple callbacks (#17706)
This PR fixes two edge cases around our client hook subscriber
management:
1. Registering the same callback instance twice on the same hook,
resulted in the callback only being invoked once. Fixed by wrapping the
passed callback in a function to "unique-ify" it.
2. Unregistering one callback synchronously within the callback, caused
other callbacks to not be invoked due to in-place, sync array mutation.
Fixed by converting the hooks data structure from `Array<Function>` to
`Set<Function>` which is resilient to sync, in-place mutation. This also
lets us remove the workaround introduced in
#17272 where we
initially discovered this bug.
Added regression tests for both cases that failed beforehand.
closes #17276 1 parent 062d684 commit 670c624
File tree
3 files changed
+123
-25
lines changed- packages
- browser-utils/src/metrics
- core
- src
- test/lib
3 files changed
+123
-25
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
226 | 226 | | |
227 | 227 | | |
228 | 228 | | |
229 | - | ||
229 | + | ||
230 | + | ||
230 | 231 | | |
231 | 232 | | |
232 | 233 | | |
233 | 234 | | |
234 | 235 | | |
235 | - | ||
236 | + | ||
236 | 237 | | |
237 | 238 | | |
238 | - | ||
239 | - | ||
240 | - | ||
241 | - | ||
242 | - | ||
243 | - | ||
244 | - | ||
245 | - | ||
246 | - | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
140 | - | ||
140 | + | ||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
| |||
685 | 685 | | |
686 | 686 | | |
687 | 687 | | |
688 | - | ||
688 | + | ||
689 | 689 | | |
690 | - | ||
691 | - | ||
690 | + | ||
691 | + | ||
692 | + | ||
693 | + | ||
694 | + | ||
695 | + | ||
696 | + | ||
697 | + | ||
692 | 698 | | |
693 | 699 | | |
694 | 700 | | |
695 | 701 | | |
696 | 702 | | |
697 | 703 | | |
698 | - | ||
699 | - | ||
700 | - | ||
701 | - | ||
702 | - | ||
704 | + | ||
703 | 705 | | |
704 | 706 | | |
705 | 707 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2397 | 2397 | | |
2398 | 2398 | | |
2399 | 2399 | | |
2400 | - | ||
2401 | 2400 | | |
2402 | - | ||
2403 | - | ||
2401 | + | ||
2404 | 2402 | | |
2405 | 2403 | | |
2406 | 2404 | | |
| |||
2420 | 2418 | | |
2421 | 2419 | | |
2422 | 2420 | | |
2423 | - | ||
2421 | + | ||
2424 | 2422 | | |
2425 | 2423 | | |
2426 | 2424 | | |
| |||
2435 | 2433 | | |
2436 | 2434 | | |
2437 | 2435 | | |
2438 | - | ||
2436 | + | ||
2439 | 2437 | | |
2440 | 2438 | | |
2441 | 2439 | | |
| |||
2450 | 2448 | | |
2451 | 2449 | | |
2452 | 2450 | | |
2451 | + | ||
2452 | + | ||
2453 | + | ||
2454 | + | ||
2455 | + | ||
2456 | + | ||
2457 | + | ||
2458 | + | ||
2459 | + | ||
2460 | + | ||
2461 | + | ||
2462 | + | ||
2463 | + | ||
2464 | + | ||
2465 | + | ||
2466 | + | ||
2467 | + | ||
2468 | + | ||
2469 | + | ||
2470 | + | ||
2471 | + | ||
2472 | + | ||
2473 | + | ||
2474 | + | ||
2475 | + | ||
2476 | + | ||
2477 | + | ||
2478 | + | ||
2479 | + | ||
2480 | + | ||
2481 | + | ||
2482 | + | ||
2483 | + | ||
2484 | + | ||
2485 | + | ||
2486 | + | ||
2487 | + | ||
2488 | + | ||
2489 | + | ||
2490 | + | ||
2491 | + | ||
2492 | + | ||
2493 | + | ||
2494 | + | ||
2495 | + | ||
2496 | + | ||
2497 | + | ||
2498 | + | ||
2499 | + | ||
2500 | + | ||
2501 | + | ||
2502 | + | ||
2503 | + | ||
2504 | + | ||
2505 | + | ||
2506 | + | ||
2507 | + | ||
2508 | + | ||
2509 | + | ||
2510 | + | ||
2511 | + | ||
2512 | + | ||
2513 | + | ||
2514 | + | ||
2515 | + | ||
2516 | + | ||
2517 | + | ||
2518 | + | ||
2519 | + | ||
2520 | + | ||
2521 | + | ||
2522 | + | ||
2523 | + | ||
2524 | + | ||
2525 | + | ||
2526 | + | ||
2527 | + | ||
2528 | + | ||
2529 | + | ||
2530 | + | ||
2531 | + | ||
2532 | + | ||
2533 | + | ||
2534 | + | ||
2535 | + | ||
2536 | + | ||
2537 | + | ||
2538 | + | ||
2539 | + | ||
2540 | + | ||
2541 | + | ||
2542 | + | ||
2543 | + | ||
2544 | + | ||
2545 | + | ||
2546 | + | ||
2547 | + | ||
2548 | + | ||
2549 | + | ||
2550 | + | ||
2551 | + | ||
2552 | + | ||
2553 | + | ||
2554 | + | ||
2555 | + | ||
2556 | + | ||
2453 | 2557 | | |
2454 | 2558 | | |
2455 | 2559 | | |
| |||
0 commit comments