Commit fd082b9
Re-throw errors from tasks and microtasks synchronously (#56513)
Summary:
Pull Request resolved: #56513
Changelog: [internal]
Fantom previously did not propagate errors thrown inside `runTask` callbacks
(or microtasks queued by them) to Jest, so failing assertions inside tasks
were silently swallowed and only logged via `console.error`. Tests had to
work around this with manual `try`/`catch` blocks and a couple of
`it.skip`s with TODOs.
This installs a Fantom-specific global error handler (via `ErrorUtils.setGlobalHandler`)
that captures the first error reported during the current work loop into
`pendingError`. After `flushMessageQueue()` returns, `runWorkLoop()`
re-throws the captured error so it becomes observable as a Jest failure.
Only the first error in a work loop is re-thrown (subsequent ones are
typically follow-on noise), and `pendingError` is cleared at the start of
each work loop so errors captured during module setup do not spuriously
fail later loops. The post-loop `runLogBoxCheck()` continues to take
precedence, since LogBox diagnostics are more actionable.
With this in place:
- The 'should throw when running a task inside another task' test can use
`expect(...).toThrow(...)` directly instead of manual try/catch.
- The two previously-skipped tests for re-throwing errors from tasks and
microtasks are now enabled.
NOTE: this will cause some tests to start failing, but they're legit failures
Reviewed By: javache
Differential Revision: D101647822
fbshipit-source-id: b9cba056d46cc94a4f6dad5e3665266df62a02111 parent f2f9209 commit fd082b9
2 files changed
Lines changed: 50 additions & 28 deletions
Lines changed: 15 additions & 27 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
119 | | - | |
120 | 119 | | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
| 120 | + | |
| 121 | + | |
126 | 122 | | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
134 | 127 | | |
135 | | - | |
136 | | - | |
137 | | - | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
138 | 131 | | |
139 | | - | |
140 | | - | |
141 | | - | |
| 132 | + | |
142 | 133 | | |
143 | | - | |
144 | | - | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
145 | 137 | | |
146 | 138 | | |
147 | | - | |
148 | | - | |
149 | | - | |
| 139 | + | |
150 | 140 | | |
151 | 141 | | |
152 | 142 | | |
153 | 143 | | |
154 | 144 | | |
155 | 145 | | |
156 | 146 | | |
157 | | - | |
158 | | - | |
159 | | - | |
| 147 | + | |
160 | 148 | | |
161 | 149 | | |
162 | 150 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
164 | 165 | | |
165 | 166 | | |
166 | 167 | | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
167 | 186 | | |
168 | 187 | | |
169 | 188 | | |
| |||
331 | 350 | | |
332 | 351 | | |
333 | 352 | | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
334 | 357 | | |
335 | 358 | | |
336 | 359 | | |
| |||
340 | 363 | | |
341 | 364 | | |
342 | 365 | | |
343 | | - | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
344 | 369 | | |
345 | 370 | | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
346 | 380 | | |
347 | 381 | | |
348 | 382 | | |
| |||
0 commit comments