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: "scheduled" template broken #4560

Closed
Akiyamka opened this issue Dec 6, 2023 · 8 comments · Fixed by #5837
Closed

🐛 BUG: "scheduled" template broken #4560

Akiyamka opened this issue Dec 6, 2023 · 8 comments · Fixed by #5837
Labels
bug Something that isn't working

Comments

@Akiyamka
Copy link

Akiyamka commented Dec 6, 2023

Which Cloudflare product(s) does this pertain to?

Workers Runtime

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

wrangler 3.19.0

What version of Node are you using?

v20.8.0

What operating system are you using?

Linux

Describe the Bug

Steps:

  1. pnpm create cloudflare@latest
  2. In which directory do you want to create your application? : ./daemon
  3. What type of application do you want to create? type Scheduled Worker (Cron Trigger)
  4. Do you want to use TypeScript?: Yes
  5. (skip deploy step)
  6. cd ./daemon
  7. npx wrangler dev
[wrangler:inf] Ready on http://localhost:8787
at __facade_modules_fetch__ (/home/user/git/_experements/ustatus/daemon/.wrangler/tmp/bundle-JfDMqA/middleware-loader.entry.ts:45:9)
   at __facade_invokeChain__ (/home/user/git/_experements/ustatus/daemon/node_modules/.pnpm/[email protected]/node_modules/wrangler/templates/middleware/common.ts:53:9)
   at Object.next (/home/user/git/_experements/ustatus/daemon/node_modules/.pnpm/[email protected]/node_modules/wrangler/templates/middleware/common.ts:50:11)
   at jsonError (/home/user/git/_experements/ustatus/daemon/node_modules/.pnpm/[email protected]/node_modules/wrangler/templates/middleware/middleware-miniflare3-json-error.ts:22:30)
   at __facade_invokeChain__ (/home/user/git/_experements/ustatus/daemon/node_modules/.pnpm/[email protected]/node_modules/wrangler/templates/middleware/common.ts:53:9)
   at __facade_invoke__ (/home/user/git/_experements/ustatus/daemon/node_modules/.pnpm/[email protected]/node_modules/wrangler/templates/middleware/common.ts:63:9)
   at Object.fetch (/home/user/git/_experements/ustatus/daemon/.wrangler/tmp/bundle-JfDMqA/middleware-loader.entry.ts:114:11)

Please provide a link to a minimal reproduction

No response

Please provide any relevant error logs

pnpm create cloudflare@latest
.../share/pnpm/store/v3/tmp/dlx-11402    | Progress: resolved 1, reused 0, dow
.../share/pnpm/store/v3/tmp/dlx-11402    |   +1 +
.../share/pnpm/store/v3/tmp/dlx-11402    | Progress: resolved 1, reused 0, dow
.../share/pnpm/store/v3/tmp/dlx-11402    | Progress: resolved 1, reused 0, dow
.../share/pnpm/store/v3/tmp/dlx-11402    | Progress: resolved 1, reused 0, dow
nloaded 1, added 1, done

using create-cloudflare version 2.8.1

╭ Create an application with Cloudflare Step 1 of 3
│
├ In which directory do you want to create your application?
│ dir ./daemon
│
├ What type of application do you want to create?
│ type Scheduled Worker (Cron Trigger)
│
├ Do you want to use TypeScript?
│ yes typescript
│
├ Copying files from "scheduled" template
│
├ Retrieving current workerd compatibility date
│ compatibility date 2023-11-21
│
╰ Application created

╭ Installing dependencies Step 2 of 3
│
├ Installing dependencies
│ installed via `pnpm install`
│
├ Installing @cloudflare/workers-types
│ installed via pnpm
│
├ Adding latest types to `tsconfig.json`
│ added @cloudflare/workers-types/2023-07-01
│
╰ Dependencies Installed

╭ Deploy with Cloudflare Step 3 of 3
│
├ Do you want to deploy your application?
│ yes deploy via `pnpm run deploy`
│
├ Logging into Cloudflare checking authentication status
│ not logged in
│
├ Logging into Cloudflare This will open a browser window
│ allowed via `wrangler login`
│
├ Selecting Cloudflare account retrieving accounts
│ account [email protected]'s Account
│
├ Deploying your application
│
> [email protected] deploy /home/user/git/_experements/ustatus/daemon
> wrangler deploy

 ⛅ wrangler 3.19.0
-------------------
Total Upload: 0.45 KiB / gzip: 0.31 KiB
▲ [WARNING] You need to register a workers.dev subdomain before publishing to workers.dev


? Would you like to register a workers.dev subdomain now?
🤖 Using default value in non-interactive context: yes

✘ [ERROR] This command cannot be run in a non-interactive context


If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose
🪵  Logs were written to "/home/user/.config/.wrangler/logs/wrangler-2023-12-06_18-46-43_164.log"
 ELIFECYCLE  Command failed with exit code 1.

│
Error:
> [email protected] deploy /home/user/git/_experements/ustatus/daemon
> wrangler deploy

 ⛅ wrangler 3.19.0
-------------------
Total Upload: 0.45 KiB / gzip: 0.31 KiB
▲ [WARNING] You need to register a workers.dev subdomain before publishing to workers.dev


? Would you like to register a workers.dev subdomain now?
🤖 Using default value in non-interactive context: yes

✘ [ERROR] This command cannot be run in a non-interactive context


If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose
🪵  Logs were written to "/home/user/.config/.wrangler/logs/wrangler-2023-12-06_18-46-43_164.log"
 ELIFECYCLE  Command failed with exit code 1.

╭─ in ~/git/_experements/ustatus on main✘✘✘
╰─± ls
daemon  devbox.json  devbox.lock  package.json
╭─ in ~/git/_experements/ustatus on main✘✘✘
╰─± cd daemon
╭─ in ~/git/_experements/ustatus/daemon on main✘✘✘
╰─±  npx wrangler dev
 ⛅ wrangler 3.19.0
-------------------
✔ Would you like to help improve Wrangler by sending usage metrics to Cloudflare? … yes
Your choice has been saved in the following file: ../../../../.config/.wrangler/metrics.json.

  You can override the user level setting for a project in `wrangler.toml`:

   - to disable sending metrics for a project: `send_metrics = false`
   - to enable sending metrics for a project: `send_metrics = true`
⎔ Starting local server...
▲ [WARNING] Miniflare 3 does not support CRON triggers yet, ignoring...


[wrangler:inf] Ready on http://localhost:8787
[wrangler:err] Error: Handler does not export a fetch() function.
    at __facade_modules_fetch__ (/home/user/git/_experements/ustatus/daemon/.wrangler/tmp/bundle-JfDMqA/middleware-loader.entry.ts:45:9)
    at __facade_invokeChain__ (/home/user/git/_experements/ustatus/daemon/node_modules/.pnpm/[email protected]/node_modules/wrangler/templates/middleware/common.ts:53:9)
    at Object.next (/home/user/git/_experements/ustatus/daemon/node_modules/.pnpm/[email protected]/node_modules/wrangler/templates/middleware/common.ts:50:11)
    at jsonError (/home/user/git/_experements/ustatus/daemon/node_modules/.pnpm/[email protected]/node_modules/wrangler/templates/middleware/middleware-miniflare3-json-error.ts:22:30)
    at __facade_invokeChain__ (/home/user/git/_experements/ustatus/daemon/node_modules/.pnpm/[email protected]/node_modules/wrangler/templates/middleware/common.ts:53:9)
    at __facade_invoke__ (/home/user/git/_experements/ustatus/daemon/node_modules/.pnpm/[email protected]/node_modules/wrangler/templates/middleware/common.ts:63:9)
    at Object.fetch (/home/user/git/_experements/ustatus/daemon/.wrangler/tmp/bundle-JfDMqA/middleware-loader.entry.ts:114:11)
[wrangler:inf] GET / 500 Internal Server Error (115ms)
[wrangler:err] Error: Handler does not export a fetch() function.
    at __facade_modules_fetch__ (/home/user/git/_experements/ustatus/daemon/.wrangler/tmp/bundle-JfDMqA/middleware-loader.entry.ts:45:9)
    at __facade_invokeChain__ (/home/user/git/_experements/ustatus/daemon/node_modules/.pnpm/[email protected]/node_modules/wrangler/templates/middleware/common.ts:53:9)
    at Object.next (/home/user/git/_experements/ustatus/daemon/node_modules/.pnpm/[email protected]/node_modules/wrangler/templates/middleware/common.ts:50:11)
    at jsonError (/home/user/git/_experements/ustatus/daemon/node_modules/.pnpm/[email protected]/node_modules/wrangler/templates/middleware/middleware-miniflare3-json-error.ts:22:30)
    at __facade_invokeChain__ (/home/user/git/_experements/ustatus/daemon/node_modules/.pnpm/[email protected]/node_modules/wrangler/templates/middleware/common.ts:53:9)
    at __facade_invoke__ (/home/user/git/_experements/ustatus/daemon/node_modules/.pnpm/[email protected]/node_modules/wrangler/templates/middleware/common.ts:63:9)
    at Object.fetch (/home/user/git/_experements/ustatus/daemon/.wrangler/tmp/bundle-JfDMqA/middleware-loader.entry.ts:114:11)
[wrangler:inf] GET /favicon.ico 500 Internal Server Error (17ms)
╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ [b] open a browser, [d] open Devtools, [l] turn off local mode, [c] clear console, [x] to exit                                                                                                                                             │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
⎔ Shutting down local server...
@Akiyamka Akiyamka added the bug Something that isn't working label Dec 6, 2023
@admah
Copy link
Contributor

admah commented Dec 6, 2023

@Akiyamka sorry you've had this issue. This appears to be a duplicate of #4263. In the meantime, you can either run wrangler deploy directly from the created folder or deploy it via the dashboard.

I wasn't able to replicate the fetch error that you have from the example code we provide.

I'm going to close this issue for now as a duplicate. Thanks!

@admah admah closed this as completed Dec 6, 2023
@admah admah added the c3 Relating to C3 (create-cloudflare) package label Dec 6, 2023
@Akiyamka
Copy link
Author

Akiyamka commented Dec 7, 2023

@admah , I'm afraid you closed this issue by mistake, my problem is not related to the "cannot be run in a non-interactive context" message (even though it is in the logs).
If you look further and pay attention to the steps I mentioned, and look at the error message - you will notice that the problem is with the worker script template.
As I managed to find out, a fetch hook must be present in the worker, which is absent in the example
To put it simply - the template contains non-valid code, it lacks the export of fetch function

@admah
Copy link
Contributor

admah commented Dec 21, 2023

@Akiyamka the template is not wrong here, other than the need for a JSON.stringify around one of the logged items. It is a valid scheduled Worker. The issue is related to some confusing error messaging that you're seeing. The browser has an automatic request for /favicon.ico that is not being handled properly by us in this instance and causing the error.

In the meantime, you can test your scheduled Worker via wrangler dev --test-scheduled and then run the scheduled event by visiting http://localhost:8787/__scheduled?cron=*+*+*+*+*. You should see the logs in your CLI, and the proper response from the URL.

@admah admah reopened this Dec 21, 2023
@admah admah removed the c3 Relating to C3 (create-cloudflare) package label Dec 21, 2023
@wim-web
Copy link

wim-web commented Jan 2, 2024

I have same issue

@wim-web
Copy link

wim-web commented Jan 2, 2024

In my environment, did not give me an error via curl, but via browser did

@arthureberledev
Copy link

i have the same issue on a fresh project initialized with npm create cloudflare@latest and selected cron job worker template (windows 11)

@kaaaaaaaaaaai
Copy link

same

@jwcheon
Copy link

jwcheon commented May 9, 2024

same issue :(

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
Archived in project
Development

Successfully merging a pull request may close this issue.

6 participants