Commit fd66a1f
committed
test(query-core): improve test to properly detect duplicate abort listeners
Based on code review feedback, the previous test approach had a flaw:
- Signal destructuring ({signal}) invokes the getter before addEventListener could be spied
- The test was not actually catching duplicate listener registrations
New approach:
- Spy on AbortSignal.prototype.addEventListener before query execution
- Access signal multiple times within queryFn to trigger getter repeatedly
- Verify that only 3 abort listeners are registered (1 per page) instead of 9 (3 per page)
This test now properly validates the memory leak fix and will fail if the
duplicate listener prevention is removed.1 parent 174e9a9 commit fd66a1f
File tree
1 file changed
+21
-20
lines changed- packages/query-core/src/__tests__
1 file changed
+21
-20
lines changedLines changed: 21 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
492 | 492 | | |
493 | 493 | | |
494 | 494 | | |
495 | | - | |
496 | | - | |
497 | 495 | | |
498 | | - | |
499 | | - | |
| 496 | + | |
| 497 | + | |
500 | 498 | | |
501 | | - | |
502 | | - | |
503 | | - | |
504 | | - | |
505 | | - | |
506 | | - | |
507 | | - | |
508 | | - | |
509 | | - | |
510 | | - | |
511 | | - | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
512 | 505 | | |
513 | | - | |
514 | | - | |
515 | | - | |
516 | | - | |
| 506 | + | |
517 | 507 | | |
518 | 508 | | |
519 | 509 | | |
| |||
527 | 517 | | |
528 | 518 | | |
529 | 519 | | |
| 520 | + | |
530 | 521 | | |
531 | 522 | | |
| 523 | + | |
532 | 524 | | |
533 | 525 | | |
534 | 526 | | |
535 | | - | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
536 | 536 | | |
| 537 | + | |
537 | 538 | | |
538 | 539 | | |
539 | 540 | | |
0 commit comments