fix(inbox): a failed PUT no longer lets the next message overtake it (4.13.1)
Some checks failed
Docker build and publish / docker (push) Has been cancelled
Publish / publish (push) Has been cancelled
Cross-platform vectors / TypeScript vectors (bun) (push) Has been cancelled
Cross-platform vectors / Kotlin vectors (gradle) (push) Has been cancelled
Test / test (push) Has been cancelled
Some checks failed
Docker build and publish / docker (push) Has been cancelled
Publish / publish (push) Has been cancelled
Cross-platform vectors / TypeScript vectors (bun) (push) Has been cancelled
Cross-platform vectors / Kotlin vectors (gradle) (push) Has been cancelled
Test / test (push) Has been cancelled
flushOnce drained a recipient's bucket in order but carried on past a failure, delivering N+1 before N's retry. For sender-key broadcasts the receiver cannot open N once past it — frozen terminal output in Prism. Stop the bucket at the first failure; other recipients still drain in parallel. Also corrects senderKeyDecrypt's doc, which claimed a skipped-key cache that never existed. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
18
CHANGELOG.md
18
CHANGELOG.md
@@ -5,6 +5,24 @@ All notable changes to Shade are documented in this file.
|
|||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [4.13.1] — 2026-10-06 — Inbox keeps per-recipient order across retries
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- **`@shade/inbox`: a failed PUT no longer lets the next message overtake it.**
|
||||||
|
`flushOnce` drained each recipient's bucket sequentially but carried on
|
||||||
|
past a failure, so entry N+1 was delivered in the same round and N only on
|
||||||
|
the retry — the recipient saw them reversed. For sender-key broadcasts that
|
||||||
|
is data loss, not cosmetics: a receiver that has advanced past iteration N
|
||||||
|
cannot open it. The bucket now stops at the first failure (head-of-line,
|
||||||
|
per recipient only; other recipients still drain in parallel). An entry
|
||||||
|
dropped at `maxAttempts` gives up its place. Found by Prism, where it
|
||||||
|
showed up as frozen terminal output on phones.
|
||||||
|
|
||||||
|
### Docs
|
||||||
|
- `senderKeyDecrypt` no longer claims a skipped-key cache it never had.
|
||||||
|
Out-of-order group messages still throw "Stale iteration"; senders must
|
||||||
|
deliver in iteration order (which the inbox fix above now guarantees).
|
||||||
|
|
||||||
## [4.11.2] — 2026-07-10 — Files pull-mode startup hotfix
|
## [4.11.2] — 2026-07-10 — Files pull-mode startup hotfix
|
||||||
|
|
||||||
**`@shade/files`**
|
**`@shade/files`**
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@shade/cli",
|
"name": "@shade/cli",
|
||||||
"version": "4.13.0",
|
"version": "4.13.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "src/cli.ts",
|
"main": "src/cli.ts",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@shade/core",
|
"name": "@shade/core",
|
||||||
"version": "4.13.0",
|
"version": "4.13.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"types": "src/index.ts",
|
"types": "src/index.ts",
|
||||||
|
|||||||
@@ -138,8 +138,13 @@ export async function senderKeyEncrypt(
|
|||||||
* Decrypt a sender key message. Verifies signature then advances the
|
* Decrypt a sender key message. Verifies signature then advances the
|
||||||
* appropriate chain key.
|
* appropriate chain key.
|
||||||
*
|
*
|
||||||
* Handles out-of-order delivery via skipped-key cache (simpler than Double
|
* Out-of-order delivery is NOT handled: the chain only moves forward and
|
||||||
* Ratchet since there's no DH ratchet).
|
* the keys of skipped iterations are discarded, so a message that arrives
|
||||||
|
* after its successor throws "Stale iteration". (This comment used to
|
||||||
|
* claim a skipped-key cache that never existed.) Senders must therefore
|
||||||
|
* deliver in iteration order — `Inbox` keeps per-recipient order across
|
||||||
|
* retries for this reason. Prism's Android receiver keeps skipped keys;
|
||||||
|
* porting that here needs a `skippedKeys` field in every storage backend.
|
||||||
*/
|
*/
|
||||||
export async function senderKeyDecrypt(
|
export async function senderKeyDecrypt(
|
||||||
crypto: CryptoProvider,
|
crypto: CryptoProvider,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@shade/crypto-web",
|
"name": "@shade/crypto-web",
|
||||||
"version": "4.13.0",
|
"version": "4.13.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"types": "src/index.ts",
|
"types": "src/index.ts",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@shade/dashboard",
|
"name": "@shade/dashboard",
|
||||||
"version": "4.13.0",
|
"version": "4.13.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@shade/files",
|
"name": "@shade/files",
|
||||||
"version": "4.13.0",
|
"version": "4.13.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"types": "src/index.ts",
|
"types": "src/index.ts",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@shade/inbox-server",
|
"name": "@shade/inbox-server",
|
||||||
"version": "4.13.0",
|
"version": "4.13.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"types": "src/index.ts",
|
"types": "src/index.ts",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@shade/inbox",
|
"name": "@shade/inbox",
|
||||||
"version": "4.13.0",
|
"version": "4.13.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"types": "src/index.ts",
|
"types": "src/index.ts",
|
||||||
|
|||||||
@@ -409,7 +409,17 @@ export class Inbox {
|
|||||||
});
|
});
|
||||||
if (attempts >= this.maxAttempts) {
|
if (attempts >= this.maxAttempts) {
|
||||||
await this.queueStore.remove(entry.recipientAddress, entry.msgId);
|
await this.queueStore.remove(entry.recipientAddress, entry.msgId);
|
||||||
|
// Given up on: it no longer holds a place in the order.
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
// Head-of-line, on purpose. Carrying on with the next entry
|
||||||
|
// delivers it AHEAD of this one, which is retried next round —
|
||||||
|
// exactly the reordering the sequential bucket exists to
|
||||||
|
// prevent. For sender-key broadcasts that is not cosmetic: a
|
||||||
|
// receiver that sees iteration N+1 first can no longer open N
|
||||||
|
// unless it kept N's key. One recipient's bucket waits; the
|
||||||
|
// others drain in parallel as before.
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
|
|||||||
@@ -467,6 +467,58 @@ describe('Inbox orchestrator', () => {
|
|||||||
await aliceInbox.tick();
|
await aliceInbox.tick();
|
||||||
expect(await aliceInbox.pendingCount()).toBe(0);
|
expect(await aliceInbox.pendingCount()).toBe(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('a failed PUT holds back the rest of its recipient\'s queue, so order survives the retry', async () => {
|
||||||
|
const store = new MemoryInboxStore();
|
||||||
|
const app = createInboxServer({ crypto, store, disableRateLimit: true });
|
||||||
|
const alice = await makeIdentity();
|
||||||
|
const bob = await makeIdentity();
|
||||||
|
const bobClient = new InboxClient({
|
||||||
|
baseUrl: 'http://localhost',
|
||||||
|
crypto,
|
||||||
|
signingPrivateKey: bob.signingPrivateKey,
|
||||||
|
fetch: honoFetch(app),
|
||||||
|
});
|
||||||
|
await bobClient.register({ address: 'bob', signingKey: bob.signingPublicKey });
|
||||||
|
|
||||||
|
// The FIRST PUT fails once. Before the fix the second envelope was
|
||||||
|
// delivered in the same round and the first only on the retry —
|
||||||
|
// bob received them in the wrong order.
|
||||||
|
let failsLeft = 1;
|
||||||
|
const flakyFetch: typeof fetch = (async (input, init) => {
|
||||||
|
const m = (init as RequestInit | undefined)?.method ?? 'GET';
|
||||||
|
const u = typeof input === 'string' ? input : input instanceof URL ? input.toString() : (input as Request).url;
|
||||||
|
if (m === 'POST' && u.includes('/v1/inbox/bob') && !u.includes('/fetch') && failsLeft > 0) {
|
||||||
|
failsLeft--;
|
||||||
|
throw new Error('transient network');
|
||||||
|
}
|
||||||
|
return honoFetch(app)(input, init);
|
||||||
|
}) as typeof fetch;
|
||||||
|
|
||||||
|
const aliceInbox = new Inbox({
|
||||||
|
baseUrl: 'http://localhost',
|
||||||
|
ownAddress: 'alice',
|
||||||
|
crypto,
|
||||||
|
signingPrivateKey: alice.signingPrivateKey,
|
||||||
|
signingPublicKey: alice.signingPublicKey,
|
||||||
|
pollIntervalMs: 0,
|
||||||
|
fetch: flakyFetch,
|
||||||
|
queueStore: new MemoryOutgoingQueueStore(),
|
||||||
|
});
|
||||||
|
const delivered: string[] = [];
|
||||||
|
aliceInbox.on((e) => {
|
||||||
|
if (e.name === 'inbox.message_delivered') delivered.push(e.data.msgId);
|
||||||
|
});
|
||||||
|
|
||||||
|
const first = await aliceInbox.send({ recipientAddress: 'bob', envelope: randBytes(40) });
|
||||||
|
const second = await aliceInbox.send({ recipientAddress: 'bob', envelope: randBytes(40) });
|
||||||
|
|
||||||
|
await aliceInbox.tick();
|
||||||
|
expect(delivered).toEqual([]);
|
||||||
|
expect(await aliceInbox.pendingCount()).toBe(2);
|
||||||
|
await aliceInbox.tick();
|
||||||
|
expect(delivered).toEqual([first, second]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('tamper detection', () => {
|
describe('tamper detection', () => {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@shade/key-transparency",
|
"name": "@shade/key-transparency",
|
||||||
"version": "4.13.0",
|
"version": "4.13.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"types": "src/index.ts",
|
"types": "src/index.ts",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@shade/keychain",
|
"name": "@shade/keychain",
|
||||||
"version": "4.13.0",
|
"version": "4.13.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"types": "src/index.ts",
|
"types": "src/index.ts",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@shade/observability",
|
"name": "@shade/observability",
|
||||||
"version": "4.13.0",
|
"version": "4.13.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"types": "src/index.ts",
|
"types": "src/index.ts",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@shade/observer",
|
"name": "@shade/observer",
|
||||||
"version": "4.13.0",
|
"version": "4.13.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"types": "src/index.ts",
|
"types": "src/index.ts",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@shade/proto",
|
"name": "@shade/proto",
|
||||||
"version": "4.13.0",
|
"version": "4.13.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"types": "src/index.ts",
|
"types": "src/index.ts",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@shade/recovery",
|
"name": "@shade/recovery",
|
||||||
"version": "4.13.0",
|
"version": "4.13.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"types": "src/index.ts",
|
"types": "src/index.ts",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@shade/sdk",
|
"name": "@shade/sdk",
|
||||||
"version": "4.13.0",
|
"version": "4.13.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"types": "src/index.ts",
|
"types": "src/index.ts",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@shade/server",
|
"name": "@shade/server",
|
||||||
"version": "4.13.0",
|
"version": "4.13.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"types": "src/index.ts",
|
"types": "src/index.ts",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@shade/storage-encrypted",
|
"name": "@shade/storage-encrypted",
|
||||||
"version": "4.13.0",
|
"version": "4.13.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"types": "src/index.ts",
|
"types": "src/index.ts",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@shade/storage-indexeddb",
|
"name": "@shade/storage-indexeddb",
|
||||||
"version": "4.13.0",
|
"version": "4.13.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"types": "src/index.ts",
|
"types": "src/index.ts",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@shade/storage-postgres",
|
"name": "@shade/storage-postgres",
|
||||||
"version": "4.13.0",
|
"version": "4.13.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"types": "src/index.ts",
|
"types": "src/index.ts",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@shade/storage-sqlite",
|
"name": "@shade/storage-sqlite",
|
||||||
"version": "4.13.0",
|
"version": "4.13.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"types": "src/index.ts",
|
"types": "src/index.ts",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@shade/streams",
|
"name": "@shade/streams",
|
||||||
"version": "4.13.0",
|
"version": "4.13.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"types": "src/index.ts",
|
"types": "src/index.ts",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@shade/transfer",
|
"name": "@shade/transfer",
|
||||||
"version": "4.13.0",
|
"version": "4.13.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"types": "src/index.ts",
|
"types": "src/index.ts",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@shade/transport-bridge",
|
"name": "@shade/transport-bridge",
|
||||||
"version": "4.13.0",
|
"version": "4.13.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"types": "src/index.ts",
|
"types": "src/index.ts",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@shade/transport-webrtc",
|
"name": "@shade/transport-webrtc",
|
||||||
"version": "4.13.0",
|
"version": "4.13.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"types": "src/index.ts",
|
"types": "src/index.ts",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@shade/transport",
|
"name": "@shade/transport",
|
||||||
"version": "4.13.0",
|
"version": "4.13.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"types": "src/index.ts",
|
"types": "src/index.ts",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@shade/vault",
|
"name": "@shade/vault",
|
||||||
"version": "4.13.0",
|
"version": "4.13.1",
|
||||||
"description": "Server-side encrypted file store for Shade — content-addressed objects with an append-only manifest log",
|
"description": "Server-side encrypted file store for Shade — content-addressed objects with an append-only manifest log",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@shade/widgets",
|
"name": "@shade/widgets",
|
||||||
"version": "4.13.0",
|
"version": "4.13.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"types": "src/index.ts",
|
"types": "src/index.ts",
|
||||||
|
|||||||
Reference in New Issue
Block a user