Skip to content
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

🐛 BUG: Wrangler chooses today's date as compatibility date instead of latest available, if none is specified by user #3639

Closed
mxschumacher opened this issue Jul 19, 2023 · 7 comments
Labels
bug Something that isn't working

Comments

@mxschumacher
Copy link

Which Cloudflare product(s) does this pertain to?

Wrangler core

What version(s) of the tool(s) are you using?

3.3.0

What version of Node are you using?

18.16.1

What operating system are you using?

Linux (Fedora 38)

Describe the Bug

TLDR: If the compability_date is not specified in wrangler.toml or passed as a command line argument, the "fallback date" should be the latest available compatibility_date and not the latest date (e.g. today). As it currently stands, the CLI basically disagrees with itself (please see full output below).

My wrangler.toml file does not contain an entry for compatibility_date

At the time of writing, the date is "2023-07-19"

As of today:

"The latest compatibility date supported by the installed Cloudflare Workers Runtime is "2023-07-17"

In a newly started project (created with npx wrangler init .), I ran the following command:

npx wrangler dev src/index.js

Please see the full output here:

npx wrangler dev src/index.js                                                                 
 ⛅️ wrangler 3.3.0
------------------
wrangler dev now uses local mode by default, powered by 🔥 Miniflare and 👷 workerd.
To run an edge preview session for your Worker, use wrangler dev --remote
▲ [WARNING] No compatibility_date was specified. Using today's date: 2023-07-19.

  Add one to your wrangler.toml file:
  
  compatibility_date = "2023-07-19"
  
  or pass it in your terminal:
  
  --compatibility-date=2023-07-19
  
  See https://developers.cloudflare.com/workers/platform/compatibility-dates/ for more information.

⎔ Starting local server...
[mf:wrn] The latest compatibility date supported by the installed Cloudflare Workers Runtime is "2023-07-17",
but you've requested "2023-07-19". Falling back to "2023-07-17"...
[mf:inf] Ready on http://127.0.0.1:8787/

Please provide a link to a minimal reproduction

No response

Please provide any relevant error logs

No response

@mxschumacher mxschumacher added the bug Something that isn't working label Jul 19, 2023
@Cherry
Copy link
Contributor

Cherry commented Jul 19, 2023

I'm not sure I'd personally consider this one a bug, but would instead consider the warning as just bad DX.

Wisdom and advice for years has been to use today's date as your compat date when starting a new project, going back to the original inception of Workers and still on the docs today. The introduction of "supported" dates and this warning is the weird part to me.

I opened an issue at cloudflare/miniflare#666 discussing this more.

@petebacondarwin
Copy link
Contributor

petebacondarwin commented Jul 20, 2023

This was resolved in #3343, which was released into wrangler@3.1.2 and create-cloudflare@2.0.11, for new projects created by npx wrangler init.

I just confirmed that this is the case:

npx wrangler@latest init . -y
 ⛅️ wrangler 3.3.0
------------------
Using npm as package manager.
▲ [WARNING] The `init` command is no longer supported. Please use `npm create cloudflare@2 -- . --wrangler-defaults` instead.

  The `init` command will be removed in a future version.


Running `npm create cloudflare@2 -- . --wrangler-defaults`...

using create-cloudflare version 2.0.13

╭ Create an application with Cloudflare Step 1 of 3
│ 
├ In which directory do you want to create your application?
│ dir ./.
│
├ What type of application do you want to create?
│ type "Hello World" Worker
│
├ Copying files from "hello-world" template
│ 
├ Retrieving current workerd compatibility date 
│ compatibility date 2023-07-17
│ 
├ Do you want to use git for version control?
│ yes git
│
╰ Application created 

╭ Installing dependencies Step 2 of 3
│ 
├ Installing dependencies 
│ installed via `npm install`
│ 
├ Committing new files 
│ git initial commit
│ 
╰ Dependencies Installed 

╭ Deploy with Cloudflare Step 3 of 3
│ 
├ Do you want to deploy your application?
│ no deploy via `npm run deploy`
│
├  APPLICATION CREATED  Deploy your application with npm run deploy
│ 
│ Navigate to the new directory: cd foooo
│ Run the development server npm run start
│ Deploy your application npm run deploy
│ Read the documentation https://developers.cloudflare.com/workers
│ Stuck? Join us at https://discord.gg/cloudflaredev
│ 
╰ See you again soon! 

Note these lines:

├ Retrieving current workerd compatibility date 
│ compatibility date 2023-07-17

@mxschumacher can you output the logs from your use of npx wrangler init? Perhaps it didn't use the latest versions of Wrangler and C3?

@mxschumacher
Copy link
Author

Hello @petebacondarwin , please note that my bug report is about what happens after I run

npx wrangler dev src/index.js

Meaning any project, not necessarily generated by C3 or similar, that does not have the compatibility_date defined in the wrangler .toml

I am using wrangler 3.3.0, you can see it at the very top of the stack trace I posted.

@petebacondarwin petebacondarwin changed the title 🐛 BUG: Wrangler chooses today's date as compatibility date instead of latest available 🐛 BUG: Wrangler chooses today's date as compatibility date instead of latest available, if none is specified by user Jul 21, 2023
@petebacondarwin
Copy link
Contributor

Oh! Sorry I missed this line in the output:

▲ [WARNING] No compatibility_date was specified. Using today's date: 2023-07-19.

and that you had removed the compatibility date from the wrangler.toml since I read these lines:

In a newly started project (created with npx wrangler init .), I ran the following command:

npx wrangler dev src/index.js

And assumed that you were using the output of npx wrangler init directly.

Updated the title of the issue to be more explicit about this.

@petebacondarwin
Copy link
Contributor

I think that the correct resolution is what I suggest in cloudflare/miniflare#666. I.e. we only warn if the local version of workerd is not latest and the date is too recent. Then for the vast majority projects this will not show a warning, and when it does it is a useful warning.

@admah
Copy link
Contributor

admah commented Oct 30, 2023

The fix for this should be available in Wrangler 3.15.0 (#4209). Could you retest and let us know if the issue is resolved?

@penalosa
Copy link
Contributor

penalosa commented May 1, 2024

This was fixed in #4209

@penalosa penalosa closed this as completed May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that isn't working
Projects
None yet
Development

No branches or pull requests

6 participants