Skip to content

fix runs.retrieve when the payload or output has unstringifiable JSON #2315

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {
conditionallyImportPacket,
createJsonErrorObject,
logger,
parsePacket,
} from "@trigger.dev/core/v3";
import { parsePacketAsJson } from "@trigger.dev/core/v3/utils/ioSerialization";
import { Prisma, TaskRunAttemptStatus, TaskRunStatus } from "@trigger.dev/database";
import assertNever from "assert-never";
import { API_VERSIONS, CURRENT_API_VERSION, RunStatusUnspecifiedApiVersion } from "~/api/versions";
Expand Down Expand Up @@ -133,7 +133,7 @@ export class ApiRetrieveRunPresenter {
});
}
} else {
$payload = await parsePacket(payloadPacket);
$payload = await parsePacketAsJson(payloadPacket);
}

if (taskRun.status === "COMPLETED_SUCCESSFULLY") {
Expand Down Expand Up @@ -162,7 +162,7 @@ export class ApiRetrieveRunPresenter {
});
}
} else {
$output = await parsePacket(outputPacket);
$output = await parsePacketAsJson(outputPacket);
}
}

Expand Down Expand Up @@ -433,7 +433,7 @@ async function resolveSchedule(run: CommonRelatedRun) {
}

async function createCommonRunStructure(run: CommonRelatedRun, apiVersion: API_VERSIONS) {
const metadata = await parsePacket({
const metadata = await parsePacketAsJson({
data: run.metadata ?? undefined,
dataType: run.metadataType,
});
Expand Down
7 changes: 4 additions & 3 deletions references/hello-world/src/trigger/example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const parentTask = task({
machine: "medium-1x",
run: async (payload: any, { ctx }) => {
logger.log("Hello, world from the parent", { payload });
await childTask.triggerAndWait({ message: "Hello, world!" });
await childTask.triggerAndWait({ message: "Hello, world!", aReallyBigInt: BigInt(10000) });
},
});

Expand Down Expand Up @@ -103,10 +103,11 @@ export const childTask = task({
message,
failureChance = 0.3,
duration = 3_000,
}: { message?: string; failureChance?: number; duration?: number },
aReallyBigInt,
}: { message?: string; failureChance?: number; duration?: number; aReallyBigInt?: bigint },
{ ctx }
) => {
logger.info("Hello, world from the child", { message, failureChance });
logger.info("Hello, world from the child", { message, failureChance, aReallyBigInt });

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