Skip to content

Commit 0d136a3

Browse files
authored
fix runs.retrieve when the payload or output has unstringifiable JSON (#2315)
1 parent c8165cc commit 0d136a3

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

apps/webapp/app/presenters/v3/ApiRetrieveRunPresenter.server.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import {
77
conditionallyImportPacket,
88
createJsonErrorObject,
99
logger,
10-
parsePacket,
1110
} from "@trigger.dev/core/v3";
11+
import { parsePacketAsJson } from "@trigger.dev/core/v3/utils/ioSerialization";
1212
import { Prisma, TaskRunAttemptStatus, TaskRunStatus } from "@trigger.dev/database";
1313
import assertNever from "assert-never";
1414
import { API_VERSIONS, CURRENT_API_VERSION, RunStatusUnspecifiedApiVersion } from "~/api/versions";
@@ -133,7 +133,7 @@ export class ApiRetrieveRunPresenter {
133133
});
134134
}
135135
} else {
136-
$payload = await parsePacket(payloadPacket);
136+
$payload = await parsePacketAsJson(payloadPacket);
137137
}
138138

139139
if (taskRun.status === "COMPLETED_SUCCESSFULLY") {
@@ -162,7 +162,7 @@ export class ApiRetrieveRunPresenter {
162162
});
163163
}
164164
} else {
165-
$output = await parsePacket(outputPacket);
165+
$output = await parsePacketAsJson(outputPacket);
166166
}
167167
}
168168

@@ -433,7 +433,7 @@ async function resolveSchedule(run: CommonRelatedRun) {
433433
}
434434

435435
async function createCommonRunStructure(run: CommonRelatedRun, apiVersion: API_VERSIONS) {
436-
const metadata = await parsePacket({
436+
const metadata = await parsePacketAsJson({
437437
data: run.metadata ?? undefined,
438438
dataType: run.metadataType,
439439
});

references/hello-world/src/trigger/example.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export const parentTask = task({
5858
machine: "medium-1x",
5959
run: async (payload: any, { ctx }) => {
6060
logger.log("Hello, world from the parent", { payload });
61-
await childTask.triggerAndWait({ message: "Hello, world!" });
61+
await childTask.triggerAndWait({ message: "Hello, world!", aReallyBigInt: BigInt(10000) });
6262
},
6363
});
6464

@@ -103,10 +103,11 @@ export const childTask = task({
103103
message,
104104
failureChance = 0.3,
105105
duration = 3_000,
106-
}: { message?: string; failureChance?: number; duration?: number },
106+
aReallyBigInt,
107+
}: { message?: string; failureChance?: number; duration?: number; aReallyBigInt?: bigint },
107108
{ ctx }
108109
) => {
109-
logger.info("Hello, world from the child", { message, failureChance });
110+
logger.info("Hello, world from the child", { message, failureChance, aReallyBigInt });
110111

111112
if (Math.random() < failureChance) {
112113
throw new Error("Random error at start");

0 commit comments

Comments
 (0)