There is a simple hello world script

There is a simple hello world script that looks like this after connecting
9 Replies
Pranshu Maheshwari
Pranshu Maheshwari•3mo ago
Things should be working fine with Queues. Could you shoot me over your script & wrangler.toml?
sharax
sharaxOP•3mo ago
I work under the web and don't have much interest in the CLI environment. I went as usual and created a new worker through the dashboard and added bindings to it.
Pranshu Maheshwari
Pranshu Maheshwari•3mo ago
could you send me your consumer code? I'll need more info to help you 🙂 everything you've described should work just fine
sharax
sharaxOP•3mo ago
you can see
Pranshu Maheshwari
Pranshu Maheshwari•3mo ago
thank you! this ~looks like a bug on our side~ is expected behavior but isn't clearly documented It's not immediately obvious from the error message, but if you add a Queue handler to your Worker code, it'll work fine again. So if your worker looks something like this:
/**
* Welcome to Cloudflare Workers! This is your first worker.
*
* - Run "npm run dev" in your terminal to start a development server
* - Open a browser tab at http://localhost:8787/ to see your worker in action
* - Run "npm run deploy" to publish your worker
*
* Learn more at https://developers.cloudflare.com/workers/
*/


export default {
async fetch(request, env, ctx) {
return new Response('Hello World!');
},

async queue(
batch,
env,
ctx
) {
console.log('Message received');
}
};
/**
* Welcome to Cloudflare Workers! This is your first worker.
*
* - Run "npm run dev" in your terminal to start a development server
* - Open a browser tab at http://localhost:8787/ to see your worker in action
* - Run "npm run deploy" to publish your worker
*
* Learn more at https://developers.cloudflare.com/workers/
*/


export default {
async fetch(request, env, ctx) {
return new Response('Hello World!');
},

async queue(
batch,
env,
ctx
) {
console.log('Message received');
}
};
sharax
sharaxOP•3mo ago
I tested this code, but it didn't work.
No description
No description
sharax
sharaxOP•3mo ago
I feel like I'm making a mistake somewhere. Because I want to establish connections like d1, etc. Can you provide a sample code or a complete one that I can use just for testing? If I can use cf queue feature sooner and produce the data in it, my problem will be solved.
Pranshu Maheshwari
Pranshu Maheshwari•3mo ago
You'll have to name the queue handler function queue, rather than q1. I'd recommend going through the getting started guide here: https://developers.cloudflare.com/queues/get-started/
Cloudflare Docs
Get started | Cloudflare Queues
Cloudflare Queues is a flexible messaging queue that allows you to queue messages for asynchronous processing. By following this guide, you will create your first queue, a Worker to publish messages to that queue, and a consumer Worker to consume messages from that queue.
Want results from more Discord servers?
Add your server