Skip to content

fix(store): fail the caller when a native-store append fails - #52

Merged
TheGreatAxios merged 1 commit into
cl-9398-mailbox-align-repo-scaffolding-with-the-package-standardfrom
cl-9434-mailbox-fail-requests-when-a-native-store-write-fails
Sep 27, 2026
Merged

TheGreatAxios merged 1 commit into
cl-9398-mailbox-align-repo-scaffolding-with-the-package-standardfrom
cl-9434-mailbox-fail-requests-when-a-native-store-write-fails

Conversation

@TheGreatAxios

Copy link
Copy Markdown
Contributor

Summary

  • Stacked on chore: align repo scaffolding with the package standard #51.
  • The native store's write queue never rejected, so a failed insert still returned 200 with an id and uid from send, writeMailboxMessage and persist, and persist announced it.
  • NativeMailboxStore.appendMessage resolves only once its own insert and mailbox_state update commit (one transaction). On failure it removes the message from the in-memory mirror, rolls uidNext and highestModSeq back, and rejects. Send, write and persist all use it: send fails before deliver, write rejects before publishing, persist logs and announces nothing.
  • NUL is dropped from header values (headerValue) and from every cached envelope field before the insert, since Postgres text/jsonb refuse it. raw keeps every byte.

Verification

  • e2e/write-failure.test.ts installs a real trigger that refuses one insert and asserts: appendMessage rejects with the counters rolled back; send returns 500 without calling deliver and the next send gets uid 1; writeMailboxMessage rejects with no bus event; persist announces nothing. It also covers NUL in the subject on send, write and persist. All 7 fail on chore: align repo scaffolding with the package standard #51.
  • bun run check, build, test:e2e and the pack smoke pass locally.

Closes CL-9434

The store's write queue swallowed every failure, so send,
writeMailboxMessage and persist reported a uid (and announced it) for a
row that never landed. appendMessage resolves only once its own insert
and counter update commit, in one transaction, and on failure rolls the
in-memory uidNext, highestModSeq and message back and rejects. Every
append in the package goes through it.

NUL is dropped from header values and cached envelope fields, since
Postgres text and jsonb refuse it; raw keeps every byte.
@TheGreatAxios
TheGreatAxios force-pushed the cl-9434-mailbox-fail-requests-when-a-native-store-write-fails branch from 73f144a to 780b43a Compare September 27, 2026 01:23
@TheGreatAxios
TheGreatAxios merged commit d1ead9f into main Sep 27, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant