cultnet-ts, cultmesh-ts: Heimdall's five Lows on send-only (spec wording, error.v1 ack-time refusal tests, build errors keep their cause, presence changelog, ack-cut anchors)
Some checks failed
CultMesh QUIC native / Build win32-x64 (pull_request) Has been skipped
CultMesh QUIC native / Build linux-x64 (pull_request) Has been skipped
CultMesh QUIC native / Release native binaries (pull_request) Has been skipped
CultMesh QUIC native / Verify committed binaries match SHA256SUMS (pull_request) Has been cancelled
CultMesh portability and performance / ubuntu-latest reactive semantics and leases (pull_request) Has been cancelled
Some checks failed
CultMesh QUIC native / Build win32-x64 (pull_request) Has been skipped
CultMesh QUIC native / Build linux-x64 (pull_request) Has been skipped
CultMesh QUIC native / Release native binaries (pull_request) Has been skipped
CultMesh QUIC native / Verify committed binaries match SHA256SUMS (pull_request) Has been cancelled
CultMesh portability and performance / ubuntu-latest reactive semantics and leases (pull_request) Has been cancelled
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
89ff3d2cbd
commit
0fbf2baea6
6 changed files with 31 additions and 5 deletions
|
|
@ -6237,8 +6237,10 @@ export class CultMesh {
|
|||
const peer = await CultMesh.createRudpPeer(runtimeId, connectionId, endpoint, options);
|
||||
try {
|
||||
if (options.sendOnly) {
|
||||
// Built outside the try: a message that cannot be serialized is the caller's error, with its cause, not a send failure.
|
||||
const put = putMessage();
|
||||
try {
|
||||
peer.send(putMessage());
|
||||
peer.send(put);
|
||||
await peer.flush(options.flushTimeoutMs ?? 30_000);
|
||||
} catch {
|
||||
throw new CultMeshRudpWriteUnconfirmedError(messageId, "local_send_failed");
|
||||
|
|
|
|||
|
|
@ -208,6 +208,17 @@ test("sendOnly fails local_send_failed when the send is never acknowledged", asy
|
|||
} finally { server.close(); }
|
||||
});
|
||||
|
||||
test("sendOnly keeps the cause of a put that cannot be built: it is not reported as local_send_failed", async () => {
|
||||
const server = await fakeServer(nextConnection, { advertise: false, answer: "silence" });
|
||||
try {
|
||||
await assert.rejects(
|
||||
CultMesh.publishRudpDocumentOnce("receipt-client", nextConnection++, server.endpoint, binding, "tests:receipt:a", { noteId: 1 } as unknown as { noteId: string; text: string }, { ...transport, sendOnly: true }),
|
||||
(error: unknown) => !(error instanceof CultMeshRudpWriteUnconfirmedError) && error instanceof Error,
|
||||
);
|
||||
assert.deepEqual(server.seen, [], "nothing was sent");
|
||||
} finally { server.close(); }
|
||||
});
|
||||
|
||||
test("sendOnly cannot be combined with writeReceipts", async () => {
|
||||
await assert.rejects(publish({ endpoint: "rudp://127.0.0.1:9" }, { sendOnly: true, writeReceipts: true }), TypeError);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ All notable changes to `@gamecult/cultnet-ts` are recorded here, following
|
|||
|
||||
### Breaking
|
||||
|
||||
- The Idunn runtime presence publisher is send-only (`sendPresenceDocument`): it returns `"sent"` once Odin's transport has acknowledged the put and no longer waits up to 500 ms for a success reply, which was never admission. It rejects `IdunnPresenceRefusedError` for a `cultnet.error.v0`, or a `cultnet.error.v1` naming the put or nothing, that arrives by the ack; a refusal after the ack is not awaited, and no other frame, one carrying the put's id included, counts as success.
|
||||
- The package is renamed `cultnet-ts` to `@gamecult/cultnet-ts` (the repo already scopes `@gamecult/cultcache-ts`), so the unscoped name cannot be claimed by someone else. Import from `@gamecult/cultnet-ts` and its subpaths; the API is unchanged.
|
||||
- `CultNetErrorMessage` carries `routingHint`, `code` and `details` (null when absent), as the reference writes them and `cultnet.error.schema.json` requires; the interface previously dropped them. New `CultNetErrorCode`, `CultNetErrorDetails` and `CultNetShardRoutingHint` types.
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import { IdunnPresenceRefusedError, sendPresenceDocument } from "../src/idunn-od
|
|||
import { CultNetRudpSession, decodeRudpPacket, encodeRudpPacket } from "../src/rudp";
|
||||
|
||||
interface Script {
|
||||
answer: "silence" | "echo" | "admitted" | "refuse-v0" | "refuse-v1-other";
|
||||
answer: "silence" | "echo" | "admitted" | "refuse-v0" | "refuse-v1-other" | "refuse-v1-same" | "refuse-v1-none";
|
||||
/** Acknowledge the put? Default true. */
|
||||
ack?: boolean;
|
||||
}
|
||||
|
|
@ -42,6 +42,8 @@ async function fakeOdin(connectionId: number, script: Script) {
|
|||
else if (script.answer === "admitted") say({ schemaVersion: "cultnet.write_admitted.v0", messageId: put.messageId, operation: "put", schemaId: "s", recordKey: "k" }, remote.port, remote.address);
|
||||
else if (script.answer === "refuse-v0") say({ schemaVersion: "cultnet.error.v0", error: "no", routingHint: null, code: "write_not_authorized", details: null }, remote.port, remote.address);
|
||||
else if (script.answer === "refuse-v1-other") say({ schemaVersion: "cultnet.error.v1", error: "no", routingHint: null, code: "write_not_authorized", details: null, messageId: "someone-else" }, remote.port, remote.address);
|
||||
else if (script.answer === "refuse-v1-same") say({ schemaVersion: "cultnet.error.v1", error: "no", routingHint: null, code: "write_not_authorized", details: null, messageId: put.messageId }, remote.port, remote.address);
|
||||
else if (script.answer === "refuse-v1-none") say({ schemaVersion: "cultnet.error.v1", error: "no", routingHint: null, code: "write_not_authorized", details: null, messageId: null }, remote.port, remote.address);
|
||||
}
|
||||
if (packet.reliable && script.ack !== false) send(session.createAckForReceived(packet.sequence), remote.port, remote.address);
|
||||
});
|
||||
|
|
@ -73,6 +75,16 @@ test("a refusal that arrives by the transport ack rejects the put", async () =>
|
|||
} finally { server.close(); }
|
||||
});
|
||||
|
||||
for (const answer of ["refuse-v1-same", "refuse-v1-none"] as const) {
|
||||
test(`an error.v1 refusal that ${answer === "refuse-v1-same" ? "names this put" : "names no put"} rejects the put`, async () => {
|
||||
const connectionId = nextConnection++;
|
||||
const server = await fakeOdin(connectionId, { answer });
|
||||
try {
|
||||
await assert.rejects(sendTo(server, "presence-1", connectionId), IdunnPresenceRefusedError);
|
||||
} finally { server.close(); }
|
||||
});
|
||||
}
|
||||
|
||||
test("a put the transport never acknowledges is an error, not sent", async () => {
|
||||
const connectionId = nextConnection++;
|
||||
const server = await fakeOdin(connectionId, { answer: "silence", ack: false });
|
||||
|
|
|
|||
Loading…
Reference in a new issue