question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

When visiting my cloudflare worker: `cfworker No fetch handler attached.

See original GitHub issue

Unfortunately when visiting the cloudflare worker URL provided by the browser page which automatically opens, I got a html page with No fetch handler attached.. I’m not sure how to fix it.

To run this, I used: webpack --watch & cfworker run worker.js -p 14000 --watch --inspect.

I have the code in this branch of the repo, the index.js is here. I am simply doing:

addEventListener('fetch', (event) => {    const url = new URL(event.request.url)
    const fetchEvent = event as FetchEvent;    fetchEvent.respondWith(new Response("HELLO there"))    
    return
  }
})

Note: it works when running without cfworker: webpack && wrangler preview --env test

Thank you for your time and help 😃

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ben-xDcommented, May 29, 2021

Thanks a lot @jdanyow, that fixed it 😃

0reactions
jdanyowcommented, May 29, 2021

@ben-xD I think the command should be something like:

cfworker run dist/worker.development.js -p 14000 --watch --inspect

Based on your webpack config: https://github.com/ben-xD/ably-cloudflare-workers/blob/main/webpack.config.js#L9-L12

You’d need to check your dist folder to find the correct filename to pass to cfworker run.

Read more comments on GitHub >

github_iconTop Results From Across the Web

FetchEvent · Cloudflare Workers docs
If no fetch event handler calls respondWith , then the runtime forwards the request to the origin as if the Worker did not....
Read more >
HTMLRewriter · Cloudflare Workers docs
The HTMLRewriter class should be instantiated once in your Workers script, with a number of handlers attached using the on and onDocument ...
Read more >
Fetch · Cloudflare Workers docs
Asynchronous tasks such as fetch are not executed at the top level in a Worker script and must be executed within a FetchEvent...
Read more >
KV · Cloudflare Workers docs
Documentation for Cloudflare Workers, a serverless execution environment that allows you to create entirely new applications or augment ...
Read more >
Limits · Cloudflare Workers docs
Bundled Workers limits are based on CPU time, rather than duration. This means that the time limit does not include the time a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found