Skip to content

[wrangler] Fix running duration calculation in workflows instances describe - #15587

Open
Kuldeeep18 wants to merge 1 commit into
cloudflare:mainfrom
Kuldeeep18:fix/workflows-describe-running-duration
Open

[wrangler] Fix running duration calculation in workflows instances describe#15587
Kuldeeep18 wants to merge 1 commit into
cloudflare:mainfrom
Kuldeeep18:fix/workflows-describe-running-duration

Conversation

@Kuldeeep18

@Kuldeeep18 Kuldeeep18 commented Sep 10, 2026

Copy link
Copy Markdown

Problem

When inspecting in-progress workflow instances, steps, or attempts (end == null) with wrangler workflows instances describe, the displayed Duration was distorted across non-UTC client timezones.

For example, a step that started 10 seconds ago displayed as running for:

  • 7 hours in America/Los_Angeles (PDT)
  • 4 hours in America/New_York (EDT)
  • 5 hours in Asia/Kolkata (IST)
  • 9 hours in Asia/Tokyo (JST)

Root Cause

In packages/wrangler/src/workflows/commands/instances/describe.ts, the current timestamp fallback for in-progress items was calculated as:

new Date(new Date().toUTCString().slice(0, -4))

Stripping " GMT" removed the timezone identifier. When passed to JavaScript's new Date(...), the string was parsed in the client's local timezone rather than UTC, shifting the epoch timestamp by the client's timezoneOffset.

In JavaScript, new Date() already represents the current instant in UTC epoch milliseconds, and new Date(start) (from an ISO 8601 UTC string) does as well. formatDistanceStrict calculates the difference between their .getTime() values, which are timezone-independent.

Solution

  • Replaced new Date(new Date().toUTCString().slice(0, -4)) with new Date() across instance, step, and attempt duration calculations in describe.ts.
  • Added a regression test in packages/wrangler/src/__tests__/workflows.test.ts asserting exact running step and attempt duration against mocked system time.
  • Added a changeset for wrangler patch release.

  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: internal CLI display calculation fix for describe.

Devin Review

@github-project-automation github-project-automation Bot moved this to Untriaged in workers-sdk Sep 10, 2026
@workers-devprod
workers-devprod requested review from a team and jamesopstad and removed request for a team September 10, 2026 09:22
@workers-devprod

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • @cloudflare/wrangler
Show detailed file reviewers
  • .changeset/fix-workflows-describe-running-duration.md: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/workflows.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/workflows/commands/instances/describe.ts: [@cloudflare/wrangler]

@devin-ai-integration devin-ai-integration Bot left a comment

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.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@pkg-pr-new

pkg-pr-new Bot commented Sep 10, 2026

Copy link
Copy Markdown
@cloudflare/autoconfig

npm i https://pkg.pr.new/@cloudflare/autoconfig@15587

@cloudflare/build-output-utils

npm i https://pkg.pr.new/@cloudflare/build-output-utils@15587

@cloudflare/codemods

npm i https://pkg.pr.new/@cloudflare/codemods@15587

@cloudflare/config

npm i https://pkg.pr.new/@cloudflare/config@15587

@cloudflare/containers-shared

npm i https://pkg.pr.new/@cloudflare/containers-shared@15587

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@15587

@cloudflare/deploy-helpers

npm i https://pkg.pr.new/@cloudflare/deploy-helpers@15587

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@15587

miniflare

npm i https://pkg.pr.new/miniflare@15587

@cloudflare/pages-functions

npm i https://pkg.pr.new/@cloudflare/pages-functions@15587

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@15587

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@15587

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@15587

@cloudflare/vitest-plugin

npm i https://pkg.pr.new/@cloudflare/vitest-plugin@15587

@cloudflare/workers-auth

npm i https://pkg.pr.new/@cloudflare/workers-auth@15587

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@15587

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@15587

wrangler

npm i https://pkg.pr.new/wrangler@15587

commit: 09e5eb2

@Kuldeeep18
Kuldeeep18 force-pushed the fix/workflows-describe-running-duration branch from 2b4d221 to 09e5eb2 Compare September 13, 2026 15:16
@changeset-bot

changeset-bot Bot commented Sep 13, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 09e5eb2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
wrangler Patch
@cloudflare/vite-plugin Patch
@cloudflare/vitest-plugin Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Untriaged

Development

Successfully merging this pull request may close these issues.

2 participants