Commit f22f67b
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 f22f67b
File tree
1 file changed
+28
-18
lines changed- packages/query-core/src/__tests__
1 file changed
+28
-18
lines changedLines changed: 28 additions & 18 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 | + | |
| 498 | + | |
500 | 499 | | |
501 | | - | |
502 | | - | |
503 | | - | |
504 | | - | |
505 | | - | |
506 | | - | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
507 | 504 | | |
508 | | - | |
509 | | - | |
510 | | - | |
511 | | - | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
512 | 508 | | |
513 | | - | |
514 | | - | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
515 | 514 | | |
516 | | - | |
| 515 | + | |
517 | 516 | | |
518 | 517 | | |
519 | 518 | | |
| |||
527 | 526 | | |
528 | 527 | | |
529 | 528 | | |
| 529 | + | |
530 | 530 | | |
531 | 531 | | |
| 532 | + | |
532 | 533 | | |
533 | 534 | | |
534 | 535 | | |
535 | | - | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
536 | 545 | | |
| 546 | + | |
537 | 547 | | |
538 | 548 | | |
539 | 549 | | |
0 commit comments