Commit 9b00720
fix(mini-oxygen): add retry and prebundle recovery to module fetch transport
MiniOxygen's module fetch transport (workerd → Vite) had no error handling
or retry logic. When Vite's fetchModule failed transiently under parallel
load (multiple dev servers in e2e tests), the transport called res.json()
on a plain-text 500 response, producing a confusing SyntaxError that
surfaced as "MiniOxygen couldn't load your app's entry point."
The root cause was twofold:
1. server-middleware.ts returned plain text on errors but the client
assumed JSON — now returns JSON errors for protocol consistency.
2. Vite's dependency optimizer can invalidate pre-bundled deps mid-request
("There is a new version of the pre-bundle"). In a browser, Vite
triggers a full page reload via HMR. But MiniOxygen runs with
hmr:false, so there was no recovery path.
This adds:
- res.ok check before res.json() with 3-attempt retry for transient 5xx
- ModuleRunner destruction + recreation on prebundle version mismatch,
emulating the browser's full-page-reload recovery behavior
- 500ms delay before retry to let the optimizer finish re-bundling
Eliminates the "MiniOxygen couldn't load entry point" flakiness that
appeared after parallel Playwright workers were enabled in #3509.
Co-Authored-By: Claude <noreply@anthropic.com>1 parent 5606796 commit 9b00720
File tree
3 files changed
+94
-18
lines changed- .changeset
- packages/mini-oxygen/src/vite
3 files changed
+94
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
200 | 200 | | |
201 | 201 | | |
202 | 202 | | |
203 | | - | |
204 | | - | |
| 203 | + | |
| 204 | + | |
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
36 | 71 | | |
37 | 72 | | |
38 | 73 | | |
| |||
90 | 125 | | |
91 | 126 | | |
92 | 127 | | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
93 | 164 | | |
94 | 165 | | |
95 | 166 | | |
| |||
106 | 177 | | |
107 | 178 | | |
108 | 179 | | |
109 | | - | |
| 180 | + | |
110 | 181 | | |
111 | 182 | | |
112 | 183 | | |
| |||
164 | 235 | | |
165 | 236 | | |
166 | 237 | | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
182 | 253 | | |
0 commit comments