Commit 60e430b
`EmailPersistence` is a public interface whose `insert` may answer with an id of
its own — a database-assigned primary key, an external delivery system's receipt
id. `sendInternal()` reserved that id as service-managed (so the `sys_email`
afterInsert outbox drain skips a row `send()` is already delivering) but its
`finally` released only the id it had minted itself, so every such message left
one entry behind for the life of the process.
The memory is the smaller half. `isServiceManaged(persistedId)` stayed true
forever, and that is a standing "this row belongs to a live send()" assertion
which both the drain hook and the boot outbox sweep (#5161) trust and nothing
ever re-checks — a row stranded at `queued` under such an id would be skipped by
every future sweep.
The id now travels in a variable declared outside the try (`extraManagedId`) and
the `finally` releases exactly what was reserved, so the release condition can
never drift from the reservation condition. The window itself is unchanged: the
release still happens after inline delivery has finalized the row and after
queue mode has published its job.
No in-repo path reached the branch — the plugin's own persistence returns the id
it was given, because ObjectQL's insert echoes `row.id` — so this was reachable
only through a custom `EmailPersistence`. Two tests pin it, one per delivery
mode, and the inline one also asserts the managed window still covers the row's
`sent` finalize so a future "release earlier" cannot pass silently.
Claude-Session: https://claude.ai/code/session_01BWS4heBoAitLmzCLhcYdbK
Co-authored-by: Claude <noreply@anthropic.com>
1 parent f2a1c0b commit 60e430b
4 files changed
Lines changed: 107 additions & 1 deletion
File tree
- .changeset
- packages/plugins/plugin-email/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 | + | |
Lines changed: 24 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
189 | 189 | | |
190 | 190 | | |
191 | 191 | | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
192 | 216 | | |
193 | 217 | | |
194 | 218 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
168 | 197 | | |
169 | 198 | | |
170 | 199 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
583 | 583 | | |
584 | 584 | | |
585 | 585 | | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
586 | 598 | | |
587 | 599 | | |
588 | 600 | | |
589 | 601 | | |
590 | 602 | | |
591 | 603 | | |
592 | 604 | | |
593 | | - | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
594 | 609 | | |
595 | 610 | | |
596 | 611 | | |
| |||
625 | 640 | | |
626 | 641 | | |
627 | 642 | | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
628 | 651 | | |
| 652 | + | |
629 | 653 | | |
630 | 654 | | |
631 | 655 | | |
| |||
0 commit comments