release: WRNexusJS 0.4.0

This commit is contained in:
2026-07-27 12:42:18 +05:30
parent 8b728a3e5d
commit 30e5721e84
250 changed files with 10065 additions and 3923 deletions
+37 -1
View File
@@ -1,6 +1,11 @@
import { test, expect } from "bun:test";
import { createContext } from "@wrnexus/core";
import { createTracker, type ErrorEvent, type ErrorSink } from "../src/index.ts";
import {
createTelemetryPipeline,
createTracker,
type ErrorEvent,
type ErrorSink,
} from "../src/index.ts";
function collectingSink(): ErrorSink & { events: ErrorEvent[] } {
const events: ErrorEvent[] = [];
@@ -59,3 +64,34 @@ test("a failing sink never breaks capture", async () => {
await tracker.capture(new Error("x")); // must not throw
expect(good.events.length).toBe(1);
});
test("telemetry requeues a failed batch only once when multiple sinks fail", async () => {
let failures = 0;
const pipeline = createTelemetryPipeline({
batchSize: 2,
flushIntervalMs: 0,
sinks: [
{
send: () => {
throw new Error("one");
},
},
{
send: () => {
throw new Error("two");
},
},
],
onSinkError: () => {
failures++;
},
});
await pipeline.emit({ kind: "event", name: "one", attributes: {} });
await pipeline.emit({ kind: "event", name: "two", attributes: {} });
expect(failures).toBe(2);
expect(pipeline.size()).toBe(2);
await pipeline.close();
expect(pipeline.size()).toBe(2);
});