Skip to content
Closed
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
4 changes: 2 additions & 2 deletions apps/webapp/app/v3/eventRepository/common.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function extractContextFromCarrier(carrier: Record<string, unknown>) {
}

export function getNowInNanoseconds(): bigint {
return BigInt(new Date().getTime() * 1_000_000);
return BigInt(Date.now()) * 1_000_000n;
}

export function getDateFromNanoseconds(nanoseconds: bigint): Date {
Expand All @@ -39,7 +39,7 @@ export function calculateDurationFromStart(
) {
const $endtime = typeof endTime === "string" ? new Date(endTime) : endTime;

const duration = Number(BigInt($endtime.getTime() * 1_000_000) - startTime);
const duration = Number(BigInt($endtime.getTime()) * 1_000_000n - startTime);

if (minimumDuration && duration < minimumDuration) {
return minimumDuration;
Expand Down
2 changes: 1 addition & 1 deletion apps/webapp/app/v3/eventRepository/index.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ async function recordRunEvent(
runId: foundRun.friendlyId,
...attributes,
},
startTime: BigInt((startTime?.getTime() ?? Date.now()) * 1_000_000),
startTime: BigInt(startTime?.getTime() ?? Date.now()) * 1_000_000n,
...optionsRest,
});

Expand Down
2 changes: 1 addition & 1 deletion apps/webapp/app/v3/runEngineHandlers.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ export function registerRunEngineEventBusHandlers() {
);

await eventRepository.recordEvent(retryMessage, {
startTime: BigInt(time.getTime() * 1000000),
startTime: BigInt(time.getTime()) * 1_000_000n,
taskSlug: run.taskIdentifier,
environment,
attributes: {
Expand Down
2 changes: 1 addition & 1 deletion apps/webapp/seed-ai-spans.mts
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ function buildAiSpanTree(params: SpanTreeParams): CreateEventInput[] {
attemptNumber?: number;
}): CreateEventInput {
const startNs = BigInt(opts.startMs) * BigInt(1_000_000);
const durationNs = opts.durationMs * 1_000_000;
const durationNs = BigInt(opts.durationMs) * BigInt(1_000_000);
return {
traceId,
spanId: opts.spanId,
Expand Down
5 changes: 5 additions & 0 deletions packages/core/src/v3/utils/durations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ export function millisecondsToNanoseconds(milliseconds: number): number {
return milliseconds * 1_000_000;
}

/** Convert epoch milliseconds to nanoseconds using BigInt to avoid overflow. */
export function epochMsToNanoseconds(ms: number): bigint {
return BigInt(ms) * 1_000_000n;
}
Comment on lines +35 to +38

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Public package changed without the required release-notes entry

A new function was added to the public core package (packages/core/src/v3/utils/durations.ts:36) without adding a changeset, which the repository rules require for any change to a published package.
Impact: The change to the published package will ship without an entry in the user-facing release notes, and CI/release tooling that enforces changesets may block the merge.

Repository rule requiring a changeset for public package changes

AGENTS.md states: "When modifying any public package (packages/* or integrations/*), add a changeset" via pnpm run changeset:add. CONTRIBUTING.md restates this: contributions to anything in /packages require a changeset before merge. This PR modifies packages/core/src/v3/utils/durations.ts (adding epochMsToNanoseconds) but the diff adds no file under .changeset/ — the only changeset present (.changeset/chat-agent-preserve-partial-on-stream-failure.md) is unrelated and pre-existing.

Prompt for agents
The PR adds a new exported function epochMsToNanoseconds to the public package packages/core/src/v3/utils/durations.ts, but no changeset accompanies the change. Per AGENTS.md and CONTRIBUTING.md, any modification to a public package under packages/* requires a changeset. Add a patch changeset (run pnpm run changeset:add, selecting @trigger.dev/core) with a user-facing description of the fix so the change appears in release notes.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.


export function formatDurationNanoseconds(nanoseconds: number, options?: DurationOptions): string {
return formatDurationMilliseconds(nanosecondsToMilliseconds(nanoseconds), options);
}
Expand Down