Repository navigation
Commit d31f707
committed
fix(compiler): detect named function expression timer loops and conditional timer ownership
Fix two bugs in the strong-effects resource leak checker:
1. rescheduleKeys now handles named function expressions passed directly
as timer callbacks (e.g. setTimeout(function tick() { setTimeout(tick, 1000); }, 1000)).
Previously it required the callback argument to be an Identifier, so inline
named function expressions that reschedule themselves were classified as
one-shot timers and escaped the leak diagnostic.
2. Timer ID ownership now propagates through ConditionalExpression and
LogicalExpression branches. Previously, const id = cond ? setInterval(fn, ms) : null
set ownership only on the conditional wrapper, so the nested setInterval
call got a null handle and clearInterval(id) in cleanup was not recognized
as a release.1 parent 1d7bb34 commit d31f707
2 files changed
Lines changed: 48 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
962 | 962 | | |
963 | 963 | | |
964 | 964 | | |
| 965 | + | |
965 | 966 | | |
966 | | - | |
967 | | - | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
968 | 976 | | |
969 | 977 | | |
970 | 978 | | |
| |||
1059 | 1067 | | |
1060 | 1068 | | |
1061 | 1069 | | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
1062 | 1082 | | |
1063 | 1083 | | |
1064 | 1084 | | |
| |||
1071 | 1091 | | |
1072 | 1092 | | |
1073 | 1093 | | |
1074 | | - | |
| 1094 | + | |
1075 | 1095 | | |
1076 | 1096 | | |
1077 | 1097 | | |
| |||
1109 | 1129 | | |
1110 | 1130 | | |
1111 | 1131 | | |
1112 | | - | |
| 1132 | + | |
1113 | 1133 | | |
1114 | 1134 | | |
1115 | 1135 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1575 | 1575 | | |
1576 | 1576 | | |
1577 | 1577 | | |
| 1578 | + | |
| 1579 | + | |
| 1580 | + | |
| 1581 | + | |
| 1582 | + | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
1578 | 1586 | | |
1579 | 1587 | | |
1580 | 1588 | | |
| |||
1583 | 1591 | | |
1584 | 1592 | | |
1585 | 1593 | | |
| 1594 | + | |
| 1595 | + | |
| 1596 | + | |
| 1597 | + | |
1586 | 1598 | | |
1587 | 1599 | | |
1588 | 1600 | | |
| |||
1789 | 1801 | | |
1790 | 1802 | | |
1791 | 1803 | | |
| 1804 | + | |
| 1805 | + | |
| 1806 | + | |
| 1807 | + | |
1792 | 1808 | | |
1793 | 1809 | | |
1794 | 1810 | | |
1795 | 1811 | | |
| 1812 | + | |
| 1813 | + | |
| 1814 | + | |
| 1815 | + | |
| 1816 | + | |
| 1817 | + | |
| 1818 | + | |
| 1819 | + | |
1796 | 1820 | | |
1797 | 1821 | | |
1798 | 1822 | | |
| |||
0 commit comments