Commit 3f42920
fix(driver-sql): keep the logger receiver at the nine detach-then-call sites — a class-based host logger no longer turns a durability warning into a TypeError (#12821)
* fix(driver-sql): keep the logger receiver at the nine detach-then-call sites
`(this.logger.error ?? this.logger.warn)(…)` evaluates to the bare function
and then calls it, so the call runs with `this === undefined`. The eight
`error ?? warn` sites now call `logDurabilityFailure()` — the property-access
helper this class already had three lines from the docblock that explained it.
The ninth is `info ?? warn` and reports a reconcile that SUCCEEDED, so it keeps
its level with an in-place property-access spelling rather than being escalated
to the durability channel.
The `:4290` docblock is rewritten: its closing paragraph explained why the
inline sites were left alone, next to code that no longer uses that shape.
Part of #12792
* test(driver-sql): pin the logger receiver with class-based doubles and a shape scan
Three sections. ⓪ asserts the doubles — and `@objectstack/core`'s real
`ObjectLogger` — are receiver-sensitive, and that a closure double is not, so
the file cannot go quietly decorative. ①/② drive the real reconcile and the
real declared-index sync (real sqlite, real duplicate rows) against a
class-based logger and against a warn-only one. ③ is a structural pin over
`sql-driver.ts`: an AST walk for all four detach shapes, with a control sample
proving it fires — including on a fallback split across lines, which the two
single-line counts on this card could not see.
Part of #12792
* predict: reverting ONE site to the detached spelling must turn the pins red
Prediction, committed before the mutation so it cannot be written after the
fact. Reverting the durability site in `syncDeclaredIndexes` to
`(this.logger.error ?? this.logger.warn)(…)` must produce, against the
class-based double:
① §2 red — the detached call throws `TypeError: Cannot read properties of
undefined (reading 'record')`, escaping `syncDeclaredIndexes`, so the
`resolves.toBeUndefined()` assertion rejects instead. The mirror of the
production shape, where `ObjectLogger.error` reaches `this.writeErrorLike`.
② §2's warn-only case red for the same reason (the FALLBACK leg detaches too).
③ §2's real-ObjectLogger case red — the platform logger, same path.
④ §3 red — the structural scan reports one `parenthesized-callee` finding.
⑤ §0 and §1 stay GREEN: they do not touch this site, so a red there would
mean the mutation was not the thing measured.
Direction: RED. Not "fewer diagnostics" and not a reversal — the assertions
are behavioural and the scan is a direct count of the shape.
Part of #12792
* predict: reverting the INFO site must turn §1 red — and in a different shape
The second ablation, because §1's assertions are about a different site on a
different channel and the first one does not cover them.
Reverting the `info` site in `reconcileAndWarnDrift` to
`(this.logger.info ?? this.logger.warn)(…)` must produce:
① §1 red — but NOT as an escaping TypeError. That site sits inside the
reconcile's own `try`, so the throw is CAUGHT and re-reported as
`[schema-drift] dev auto-reconcile failed … — falling back to warning`.
So the failure is `infos` empty AND a bogus failure line present: a
reconcile that really happened, announced as a failure.
② §1's warn-only case red the same way (the fallback leg detaches too).
③ §3 red — one more `parenthesized-callee` finding.
④ §0 and §2 stay GREEN.
Direction: RED, via SWALLOW-AND-MISLABEL rather than a propagating throw.
That asymmetry is the point of running this one separately.
Part of #12792
* test(driver-sql): assert the reconcile's whole log transcript, not just the line wanted
The info site's defect has two halves and the second one is a line that must
NOT be present: the site sits inside the reconcile's own `try`, so a detached
call is caught and re-reported as `dev auto-reconcile failed`. Asserting the
full transcript puts both halves in one diff instead of hiding the mislabel
behind an earlier expectation that fails first.
Part of #12792
* chore: changeset for the driver-sql logger receiver fix
Part of #12792
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent c4ecf0c commit 3f42920
3 files changed
Lines changed: 627 additions & 13 deletions
File tree
- .changeset
- packages/drivers/driver-sql/src
| 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 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
0 commit comments