Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): bound provider event log records before serialization #12305

Mergedjuliusmarmingemerged 2 commits intomain fromrefs/pull/12305/headmerged by juliusmarminge View on GitHub

Showing 2 changed files with 171 additions and 2 deletions (loading 1).

x
0 of 2 viewed, 2 left
171 additions and 2 deletionsapps/server/src/provider/Layers/EventNdjsonLogger.test.tsModified
View file
@@ -21,6 +21,7 @@
} from "./EventNdjsonLogger.ts";
​
const encodeUnknownJson = Schema.encodeUnknownSync(Schema.fromJsonString(Schema.Unknown));
+const decodeUnknownJson = Schema.decodeUnknownSync(Schema.fromJsonString(Schema.Unknown));
​
function ownedLogPath(basePath: string, segment: string): string {
const basename = NodePath.basename(basePath);
@@ -49,7 +50,7 @@
​
describe("EventNdjsonLogger", () => {
- it.effect("logs bounded diagnostics when an event cannot be serialized", () => {
+ it.effect("summarizes circular events without exposing their contents in diagnostics", () => {
const messages: Array<unknown> = [];
const logCapture = Logger.make<unknown, void>(({ message }) => {
if (Array.isArray(message)) {
@@ -71,10 +72,14 @@
assert.exists(logger);
if (!logger) return;
yield* logger.write(circular, ThreadId.make("thread-1"));
+ yield* logger.close();
​
const serialized = encodeUnknownJson(messages);
assert.notInclude(serialized, secret);
- assert.include(serialized, '"errorTag":"SchemaError"');
+ const line = parseLogLine(
+ NodeFS.readFileSync(ownedLogPath(basePath, "thread-1"), "utf8").trim(),