Commit 37a7d13
fix(cli): stop leaking a mutated Error.prepareStackTrace from config loading
loadMetaobjectsConfig permanently mutated the process-global
Error.prepareStackTrace. When Bun's native import of a config fails (a config
whose module body throws, say), jiti falls back to its bundled Babel
transformer, whose rewrite-stack-trace installs a prepareStackTrace wrapper
delegating to whatever it captured — and never restores it. On Node the
captured value is undefined, so Babel's lenient fallback runs and nothing is
harmed. On Bun it is Bun's NATIVE default, which throws
`TypeError: First argument must be an Error object` for any target that is not
a real ErrorInstance.
Once leaked, every later legacy-constructor error in the process throws that
TypeError WHILE BEING CONSTRUCTED, destroying its real message. libsql's
SqliteError is exactly that shape (ES5 constructor + Error.captureStackTrace),
so a genuine "CHECK constraint failed: …" surfaced as "First argument must be
an Error object". The loader now snapshots and restores the hook (and
stackTraceLimit); restoring is safe because Babel's installer self-neuters
after its first call.
How it hid is the more useful part: the damage is cross-package, and every CI
lane runs `bun test` PER PACKAGE, so cli and migrate-ts never shared a process.
Only a workspace-wide `bun test` — the run the contributor docs invite — showed
it, as four migrate-ts real-engine gates failing on their error-MESSAGE
assertions while the migrate engine behaved correctly. No migration-correctness
defect was masked: the constraints fired and every apply → introspect →
re-diff-EMPTY loop completed.
Also hardens three assertions in sqlite-uuid-pk-kitchen-sink that were not
merely weak but VACUOUS: `expect(p).rejects.toThrow()` without `await` returns
a promise and never gates the test, so three "VALUE SEMANTICS" checks asserted
nothing and passed throughout the pollution. Now awaited and matched on /CHECK/i.
The workspace-wide suite is green for the first time: 5763 pass, 24 skip,
0 fail across 652 files (was 4 fail). Fix and regression test are
mutation-verified — both tests fail with the restore removed.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KTGT5ksntpcJDZVJ5VyXHS1 parent b852475 commit 37a7d13
4 files changed
Lines changed: 117 additions & 3 deletions
File tree
- server/typescript/packages
- cli
- src/lib
- test/unit
- migrate-ts/test/integration
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
10 | 43 | | |
11 | 44 | | |
12 | 45 | | |
| |||
Lines changed: 21 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
209 | 209 | | |
210 | 210 | | |
211 | 211 | | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
212 | 225 | | |
213 | 226 | | |
214 | 227 | | |
| |||
221 | 234 | | |
222 | 235 | | |
223 | 236 | | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
224 | 245 | | |
225 | 246 | | |
226 | 247 | | |
| |||
Lines changed: 60 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 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 | + | |
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
224 | | - | |
| 224 | + | |
225 | 225 | | |
226 | 226 | | |
227 | 227 | | |
| |||
250 | 250 | | |
251 | 251 | | |
252 | 252 | | |
253 | | - | |
| 253 | + | |
254 | 254 | | |
255 | 255 | | |
256 | 256 | | |
| |||
282 | 282 | | |
283 | 283 | | |
284 | 284 | | |
285 | | - | |
| 285 | + | |
286 | 286 | | |
287 | 287 | | |
288 | 288 | | |
| |||
0 commit comments