Commit edb2bcc
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 edb2bcc
File tree
1 file changed
+30
-27
lines changed- packages/query-core/src/__tests__
1 file changed
+30
-27
lines changedLines changed: 30 additions & 27 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 | | - | |
512 | | - | |
513 | | - | |
514 | | - | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
515 | 505 | | |
516 | | - | |
| 506 | + | |
517 | 507 | | |
518 | 508 | | |
519 | 509 | | |
| |||
527 | 517 | | |
528 | 518 | | |
529 | 519 | | |
530 | | - | |
531 | | - | |
532 | | - | |
533 | | - | |
534 | | - | |
535 | | - | |
536 | | - | |
537 | | - | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
538 | 541 | | |
539 | 542 | | |
0 commit comments