Skip to content

Remove getLocalWorkerdCompatibilityDate from workers-utils and re-export supportedCompatibilityDate from miniflare instead#12387

Closed
dario-piotrowicz wants to merge 27 commits intomainfrom
dario/DEVX-2446/miniflare-getLocalWorkerdCompatibilityDate
Closed

Remove getLocalWorkerdCompatibilityDate from workers-utils and re-export supportedCompatibilityDate from miniflare instead#12387
dario-piotrowicz wants to merge 27 commits intomainfrom
dario/DEVX-2446/miniflare-getLocalWorkerdCompatibilityDate

Conversation

@dario-piotrowicz
Copy link
Copy Markdown
Member

@dario-piotrowicz dario-piotrowicz commented Feb 3, 2026

Fixes https://jira.cfdata.org/browse/DEVX-2446

This PR removes the getLocalWorkerdCompatibilityDate utility from the @cloudflare/worker-utils package and makes sure that the miniflare's supportedCompatibilityDate is exposed by the package. The same variable is then re-exported by wrangler.

This value is then also used by C3 ensuring that the compatibility date can be reliably retrieved when using pnpm.


A picture of a cute animal (not mandatory, but encouraged)


Open with Devin

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Feb 3, 2026

🦋 Changeset detected

Latest commit: c9ccae5

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

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

@claude
Copy link
Copy Markdown
Contributor

claude bot commented Feb 3, 2026

Claude finished @dario-piotrowicz's task —— View job


Changeset Review

Reviewing changesets for this PR...

Tasks:

  • Read changeset guidelines
  • Review .changeset/dirty-moments-join.md
  • Review .changeset/long-colts-occur.md
  • Review .changeset/quiet-roses-help.md
  • Review .changeset/smart-buckets-wonder.md
  • Provide final assessment

⚠️ Issues Found

.changeset/long-colts-occur.md (@cloudflare/vite-plugin)

Issue: Typo in changeset description - supportedCompatibility should be supportedCompatibilityDate

The description says:

miniflare exports the latest compatibility date supportedCompatibility as, and that is the value that now the package uses...

Should be:

miniflare exports the latest compatibility date supportedCompatibilityDate as, and that is the value that now the package uses...

Also, the sentence structure is awkward with "exports...as, and that is" - consider rephrasing to:

miniflare exports the latest compatibility date as supportedCompatibilityDate, and that is the value that the package now uses...


All other changesets look good:

  • .changeset/dirty-moments-join.md (wrangler minor) - Appropriate version type and clear description
  • .changeset/quiet-roses-help.md (create-cloudflare patch) - Concise bug fix description
  • .changeset/smart-buckets-wonder.md (@cloudflare/workers-utils minor) - Appropriate version type for removing a function from a 0.x package

Comment thread packages/workers-utils/src/compatibility-date.ts Outdated
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Feb 3, 2026

create-cloudflare

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

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-shared

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

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@12387

@cloudflare/workers-editor-shared

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

wrangler

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

commit: c9ccae5

Comment thread .changeset/dirty-moments-join.md Outdated
Comment thread packages/miniflare/src/runtime/index.ts Outdated
@vicb
Copy link
Copy Markdown
Contributor

vicb commented Feb 4, 2026

@dario-piotrowicz could you please take a look at #11910 - looks like both PR handle the same thing?

@dario-piotrowicz
Copy link
Copy Markdown
Member Author

@dario-piotrowicz could you please take a look at #11910 - looks like both PR handle the same thing?

I commented there, I think there's little benefit in merging #11910 since that doesn't solve the pnpm issue

@dario-piotrowicz dario-piotrowicz requested a review from vicb February 4, 2026 10:47
@dario-piotrowicz dario-piotrowicz marked this pull request as ready for review February 4, 2026 11:08
@dario-piotrowicz dario-piotrowicz requested a review from a team as a code owner February 4, 2026 11:08
Copy link
Copy Markdown
Contributor

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

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 potential bugs to report.

View in Devin Review to see 4 additional flags.

Open in Devin Review

@petebacondarwin
Copy link
Copy Markdown
Contributor

This all feels very convoluted 😢. Especially where we have to try to import wrangler in the workers-utils package.

@dario-piotrowicz
Copy link
Copy Markdown
Member Author

This all feels very convoluted 😢. Especially where we have to try to import wrangler in the workers-utils package.

But that's a temporary solution / workaround, in a followup PR I am planning to remove the function from workers-utils, so at that point we'll only have:

  • getLocalWorkerdCompatibilityDate exported by miniflare (for direct miniflare users)
  • getLocalWorkerdCompatibilityDate re-exported by wrangler (for anyone using wrangler programmatically)
  • C3 using wrangler's getLocalWorkerdCompatibilityDate (in a way analogous to what workers-utils does today)

I think that that would be quite clean and clear, no?

@petebacondarwin
Copy link
Copy Markdown
Contributor

Can we not just do that in one go here in this PR?
I feel like the workaround makes this PR more complicated that if we just did the full move now.

@dario-piotrowicz
Copy link
Copy Markdown
Member Author

Can we not just do that in one go here in this PR? I feel like the workaround makes this PR more complicated that if we just did the full move now.

I wanted to go this way because I think it's safer (and I didn't think it'd introduce too much complexity), I'm happy to do all of that in one go if that's the preference 🙂

@dario-piotrowicz dario-piotrowicz marked this pull request as draft February 4, 2026 15:13
@dario-piotrowicz dario-piotrowicz force-pushed the dario/DEVX-2446/miniflare-getLocalWorkerdCompatibilityDate branch from 2d8af12 to c4a0c37 Compare February 4, 2026 17:52
@dario-piotrowicz dario-piotrowicz changed the title Add getLocalWorkerdCompatibiltyDate to miniflare Move getLocalWorkerdCompatibiltyDate to miniflare Feb 4, 2026
@dario-piotrowicz dario-piotrowicz force-pushed the dario/DEVX-2446/miniflare-getLocalWorkerdCompatibilityDate branch 2 times, most recently from c2d82c4 to 40a4b0a Compare February 4, 2026 18:08
@dario-piotrowicz
Copy link
Copy Markdown
Member Author

@petebacondarwin PR updated to remove the extra complexity 🙂

@dario-piotrowicz dario-piotrowicz marked this pull request as ready for review February 4, 2026 19:01
@dario-piotrowicz dario-piotrowicz requested a review from a team as a code owner February 4, 2026 19:01
devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

@dario-piotrowicz dario-piotrowicz requested a review from vicb March 24, 2026 11:37
Copy link
Copy Markdown
Contributor

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

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

Bunch of comments - I think mostly nits - so marking as approved.

Comment thread .changeset/dirty-moments-join.md Outdated
Comment thread .changeset/quiet-roses-help.md Outdated
Comment thread .changeset/quiet-roses-help.md Outdated
Comment thread .changeset/smart-buckets-wonder.md
Comment thread packages/create-cloudflare/src/helpers/__tests__/compatDate.test.ts
Comment thread packages/miniflare/test/runtime/compatibility-date.spec.ts Outdated
Comment thread packages/miniflare/README.md Outdated

### `supportedCompatibilityDate`

Exported value containing the latest [compatibility date](https://developers.cloudflare.com/workers/platform/compatibility-dates/) supported by the locally installed `workerd` package. If the `workerd` package's compatibility date is in the future, the value contains today's date instead. The value is a string in the `YYYY-MM-DD` format (e.g. `"2025-09-27"`).
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.

I think it is worth explaining the logic for compat dates again here...

Each workerd release exposes a supported compat date that it guarantees can be used with this version of the package. This date is up to 7 days after the release date of the version.
Normally this supportedCompatibilityDate is equal to the value exported by workerd, but if this supported compat date is in the future (because the workerd package was released in the last 7 days) then the value of this export is today.

Comment thread packages/wrangler/src/api/integrations/platform/index.ts
Comment thread packages/wrangler/src/api/index.ts Outdated
Comment thread packages/wrangler/src/autoconfig/run.ts Outdated
Copy link
Copy Markdown
Contributor

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

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

View 12 additional findings in Devin Review.

Open in Devin Review

Comment thread packages/create-cloudflare/e2e/tests/workers/workers.test.ts
// supportedCompatibilityDate is already a YYYY-MM-DD string, which sorts
// lexicographically as a date. Compare directly against today's date.
const todayDate = formatCompatibilityDate(new Date());
expect(supportedCompatibilityDate <= todayDate).toBe(true);
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.

Suggested change
expect(supportedCompatibilityDate <= todayDate).toBe(true);
expect(supportedCompatibilityDate).toBeLessThanOrEqual(todayDate);

@dario-piotrowicz
Copy link
Copy Markdown
Member Author

Closing in favour of #13051

@github-project-automation github-project-automation bot moved this from In Review to Done in workers-sdk Mar 25, 2026
@dario-piotrowicz dario-piotrowicz deleted the dario/DEVX-2446/miniflare-getLocalWorkerdCompatibilityDate branch March 25, 2026 01:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants