Skip to content

Commit 63959ab

Browse files
committed
Mo-Stashed changes
1 parent 7d333e5 commit 63959ab

3 files changed

Lines changed: 45 additions & 2 deletions

File tree

apps/webapp/app/routes/resources.taskruns.$runParam.replay.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
108108
const disableVersionSelection = environment.type === "DEVELOPMENT";
109109
const allowArbitraryQueues = backgroundWorkers.at(0)?.engine === "V1";
110110

111+
const payload = await prettyPrintPacket(run.payload, run.payloadType, {
112+
cloneCircularReferences: false,
113+
});
114+
111115
return typedjson({
112116
concurrencyKey: run.concurrencyKey,
113117
maxAttempts: run.maxAttempts,
@@ -116,7 +120,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
116120
ttlSeconds: run.ttl ? parseDuration(run.ttl, "s") ?? undefined : undefined,
117121
idempotencyKey: run.idempotencyKey,
118122
runTags: run.runTags,
119-
payload: await prettyPrintPacket(run.payload, run.payloadType),
123+
payload,
120124
payloadType: run.payloadType,
121125
queue: run.queue,
122126
metadata: run.seedMetadata

packages/core/src/v3/utils/ioSerialization.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ export async function prettyPrintPacket(
391391
}
392392
const { deserialize } = await loadSuperJSON();
393393

394-
return await prettyPrintPacket(deserialize(rawData), "application/json");
394+
return await prettyPrintPacket(deserialize(rawData), "application/json", options);
395395
}
396396

397397
if (dataType === "application/json") {
@@ -410,6 +410,7 @@ export async function prettyPrintPacket(
410410

411411
interface ReplacerOptions {
412412
filteredKeys?: string[];
413+
cloneCircularReferences?: boolean;
413414
}
414415

415416
function makeSafeReplacer(options?: ReplacerOptions) {
@@ -418,6 +419,10 @@ function makeSafeReplacer(options?: ReplacerOptions) {
418419
return function replacer(key: string, value: any) {
419420
if (typeof value === "object" && value !== null) {
420421
if (seen.has(value)) {
422+
if (options?.cloneCircularReferences) {
423+
return structuredClone(value);
424+
}
425+
421426
return "[Circular]";
422427
}
423428
seen.add(value);
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { logger, task } from "@trigger.dev/sdk";
2+
3+
export const circularPayloadParentTask = task({
4+
id: "circular-payload-parent",
5+
run: async (payload: any) => {
6+
const circularReferencePayload = {
7+
name: "Alice",
8+
details: {
9+
age: 30,
10+
email: "alice@example.com",
11+
},
12+
};
13+
14+
// @ts-expect-error - This is a circular reference
15+
circularReferencePayload.details.user = circularReferencePayload;
16+
17+
await circularPayloadChildTask.triggerAndWait(circularReferencePayload);
18+
19+
return {
20+
message: "Hello, world!",
21+
};
22+
},
23+
});
24+
25+
export const circularPayloadChildTask = task({
26+
id: "circular-payload-child",
27+
run: async (payload: any) => {
28+
logger.log("response", { response: payload.response });
29+
30+
return {
31+
message: "Hello, world!",
32+
};
33+
},
34+
});

0 commit comments

Comments
 (0)