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(new Date().getTime()) * BigInt(1_000_000);

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.

🟡 Server-only change ships without a release-notes entry

This change only touches server code under apps/webapp/ but no .server-changes/ note was added (see CONTRIBUTING.md and AGENTS.md), so the fix will be missing from the user-visible release notes.
Impact: Users reading the release notes won't see that the timestamp accuracy issue was fixed.

Repository rule: server-only PRs require a .server-changes entry

CONTRIBUTING.md states: "If your PR only changes server components (apps/webapp/, apps/supervisor/, etc.) with no package changes, add a .server-changes/ file so the change appears in release notes." The diff modifies only apps/webapp/app/v3/eventRepository/common.server.ts, apps/webapp/app/v3/eventRepository/index.server.ts and apps/webapp/app/v3/runEngineHandlers.server.ts, and the branch adds no file under .server-changes/. The file needs frontmatter area: webapp and type: fix plus a one-line user-facing description.

Prompt for agents
The PR changes only server code under apps/webapp, so per CONTRIBUTING.md and AGENTS.md it needs a markdown file in .server-changes/ (e.g. .server-changes/fix-event-timestamp-precision.md) with frontmatter 'area: webapp' and 'type: fix', and a one-line, user-facing body describing the behavior change (e.g. run timeline timestamps are now recorded exactly instead of being off by a fraction of a microsecond). Follow the writing guidance in .server-changes/README.md.
Open in Devin Review

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

}

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()) * BigInt(1_000_000) - 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()) * BigInt(1_000_000),

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.

🔍 Fix changes stored timestamp values; verify no downstream equality/dedup depends on old rounded values

Timestamps produced by getNowInNanoseconds/recordRunEvent/the retry event now carry exact nanosecond values instead of values rounded to the nearest 256ns. Any persisted data written before this change (ClickHouse/Postgres task events) keeps the old rounded values, so exact-equality comparisons or joins between newly written start times and previously derived values (e.g. span start/end matching, dedup keys built from start time) could behave differently across the deploy boundary. Callers I checked compute durations or ranges rather than exact matches, so this appears safe, but it's worth a second look at anything keying on startTime exactly.

Open in Devin Review

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

...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()) * BigInt(1_000_000),
taskSlug: run.taskIdentifier,
environment,
attributes: {
Expand Down