Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): failed telemetry batches stop re-sending every second #14986

Mergedt3dotgg(GitHub profile, opens in a new tab)merged 4 commits intofix/ws-reconnect-backoff fromrefs/pull/14986/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHub

Showing 11 changed files with 83 additions and 0 deletions (loading 10).

x
0 of 11 viewed, 11 left
83 additions and 0 deletionsapps/server/src/telemetry/AnalyticsService.test.tsModified
View file
@@ -4,6 +4,10 @@
import * as ConfigProvider from "effect/ConfigProvider";
import * as Effect from "effect/Effect";
import * as Layer from "effect/Layer";
+import * as Schema from "effect/Schema";
+import * as TestClock from "effect/testing/TestClock";
+import * as HttpClient from "effect/unstable/http/HttpClient";
+import * as HttpClientError from "effect/unstable/http/HttpClientError";
import * as HttpServer from "effect/unstable/http/HttpServer";
import * as HttpServerRequest from "effect/unstable/http/HttpServerRequest";
import * as HttpServerResponse from "effect/unstable/http/HttpServerResponse";
@@ -46,7 +50,86 @@
}>;
​
+const SentBatch = Schema.fromJsonString(
+ Schema.Struct({
+ batch: Schema.Array(Schema.Struct({ uuid: Schema.String })),
+ }),
+);
+​
+/**
+ * HTTP client that reads each batch, then fails as if the connection dropped
+ * before the response arrived. PostHog stores these batches, so the server
+ * must not send them forever.
+ */
+const acceptThenFailClient = (batches: Array<ReadonlyArray<{ readonly uuid: string }>>) =>
+ Layer.succeed(
+ HttpClient.HttpClient,