Commit dca7626
fix(core): restore sessions and propagate errors on session/within/retryTo error paths
Fixes four of the latent error-path divergences characterized in #5622, by
making the error paths symmetric with the success paths. The characterization
assertions are updated to the corrected behavior in the same commit.
- within() async error (lib/effects.js): the catch now calls finishHelpers()
(so helpers' _withinEnd runs on error, not just success) and returns
recorder.promise() (so the error propagates through within() instead of being
detached onto a trailing task that a caller awaiting within() never sees).
- session() async error (lib/session.js): schedules a recorder task that runs
recorder.session.restore so the recorder session is restored on error (it
was only restored on success, leaking the session id). The existing
restoreVars/listener cleanup is kept as-is — switching to finalize()'s real
restoreVars() closes the browser context under BROWSER_RESTART=session.
- session() sync error (lib/session.js): the finally recorder.catch now calls
recorder.session.restore before re-throwing (the only place that runs on a
rejected chain).
- retryTo() (lib/effects.js): a thrown callback no longer reject()s the outer
promise prematurely — it routes through recorder.throw so the retry logic
owns the outcome (retry, or reject once maxTries is exhausted). A callback
that throws then succeeds on a later attempt now resolves instead of
rejecting. tries now starts at 1 on the first attempt (was 2); the retry
count is preserved (tries < maxTries).
Verified: unit 748/0, runner 273/0 (incl. all retryFailedStep/rerun tests),
acceptance within/session/els green under both BROWSER_RESTART=browser and
=session.
Not changed here (would be unsafe or out of scope, see PR):
recorder.retries clearing (retryFailedStep depends on it), the stopped-recorder
no-op contract, and nested cross-level restore ordering.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent 5f51d3e commit dca7626
3 files changed
Lines changed: 44 additions & 29 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
53 | 54 | | |
54 | 55 | | |
| 56 | + | |
55 | 57 | | |
56 | 58 | | |
57 | 59 | | |
| |||
203 | 205 | | |
204 | 206 | | |
205 | 207 | | |
206 | | - | |
| 208 | + | |
207 | 209 | | |
208 | 210 | | |
209 | 211 | | |
| |||
216 | 218 | | |
217 | 219 | | |
218 | 220 | | |
219 | | - | |
| 221 | + | |
220 | 222 | | |
221 | 223 | | |
222 | 224 | | |
| |||
228 | 230 | | |
229 | 231 | | |
230 | 232 | | |
231 | | - | |
| 233 | + | |
232 | 234 | | |
233 | 235 | | |
234 | 236 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
| 112 | + | |
112 | 113 | | |
113 | 114 | | |
114 | 115 | | |
| |||
124 | 125 | | |
125 | 126 | | |
126 | 127 | | |
| 128 | + | |
127 | 129 | | |
128 | 130 | | |
129 | 131 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
97 | | - | |
| 97 | + | |
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
107 | 106 | | |
108 | 107 | | |
109 | | - | |
| 108 | + | |
110 | 109 | | |
111 | 110 | | |
112 | 111 | | |
113 | 112 | | |
114 | 113 | | |
115 | 114 | | |
116 | | - | |
117 | | - | |
118 | 115 | | |
119 | 116 | | |
120 | | - | |
121 | | - | |
| 117 | + | |
| 118 | + | |
122 | 119 | | |
123 | 120 | | |
124 | 121 | | |
| |||
134 | 131 | | |
135 | 132 | | |
136 | 133 | | |
137 | | - | |
| 134 | + | |
138 | 135 | | |
139 | 136 | | |
140 | 137 | | |
141 | 138 | | |
142 | | - | |
143 | | - | |
144 | | - | |
| 139 | + | |
145 | 140 | | |
146 | 141 | | |
147 | | - | |
| 142 | + | |
148 | 143 | | |
149 | 144 | | |
150 | 145 | | |
151 | 146 | | |
152 | | - | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
153 | 168 | | |
154 | 169 | | |
155 | 170 | | |
| |||
165 | 180 | | |
166 | 181 | | |
167 | 182 | | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
| 183 | + | |
| 184 | + | |
173 | 185 | | |
174 | | - | |
175 | | - | |
176 | | - | |
| 186 | + | |
| 187 | + | |
177 | 188 | | |
178 | 189 | | |
179 | 190 | | |
| |||
0 commit comments