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: Cloudflare Worker Queue Consumer Not Executing in Production #6619

Closed
DevAwais92 opened this issue Sep 3, 2024 · 3 comments
Closed
Labels
awaiting reporter response Needs clarification or followup from OP bug Something that isn't working

Comments

@DevAwais92
Copy link

Which Cloudflare product(s) does this pertain to?

Queues

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

Wrangler: 3.73.0, Queues Beta

What version of Node are you using?

20.11.0

What operating system and version are you using?

Windows 11

Describe the Bug

I have created a Cloudflare Worker to handle queues with the following configuration. The worker successfully processes queue messages in development mode locally. However, when deployed to production, the consumer queue does not execute as expected. The only log output I receive is from the console.log('queue request received', env); in the fetch event, and the consumer queue is not triggered. in queues dashboard messages are being queued. and lastly in production env contains this data to when logging.

(log) queue request received {
OFFLINE_SALES_QUEUE: {},
}

index.js File for Queue Handling

export default {
  async fetch(request, env, ctx) {
    console.log('queue request received', env);
    const message = 'Hello World! from Cloudflare Workers.';
    await env.OFFLINE_SALES_QUEUE.send({ message });
    return new Response('Message queued successfully.', { status: 200 });
  },
  async queue(batch, env) {
    console.log('initializingDB connection');

    await initializeDB(env);

    console.log('Received batch');
    console.log(`consumed from our queue: ${batch.messages}`);

    const Sale = DB(DBConstants.collections.sales);

    const doc = await Sale.insertOne({
      message: 'Testing Queues',
    });

    console.log('sale doc:', doc.insertedId);
  },
};

wrangler.toml File for Queue Configuration

queues.producers = [
{ queue = "offline-sales-queue", binding = "OFFLINE_SALES_QUEUE" }
]

queues.consumers = [
{ queue = "offline-sales-queue", retry_delay = 60, type = "http_pull", max_retries = 3, max_batch_size = 10, max_batch_timeout = 3 }
]

[env.production]

env.production.queues.producers = [
{ queue = "offline-sales-queue", binding = "OFFLINE_SALES_QUEUE" }
]

env.production.queues.consumers = [
{ queue = "offline-sales-queue", retry_delay = 60, type = "http_pull", max_retries = 3, max_batch_size = 10, max_batch_timeout = 3 }
]

Please provide a link to a minimal reproduction

No response

Please provide any relevant error logs

No response

@DevAwais92 DevAwais92 added the bug Something that isn't working label Sep 3, 2024
@github-project-automation github-project-automation bot moved this to Untriaged in workers-sdk Sep 3, 2024
@emily-shen
Copy link
Contributor

Can you provide a link to a github repo with a minimal reproduction that shows the bug so we can test it? Thanks!

@emily-shen emily-shen added the awaiting reporter response Needs clarification or followup from OP label Sep 16, 2024
@emily-shen emily-shen moved this from Untriaged to Backlog in workers-sdk Sep 16, 2024
@DevAwais92
Copy link
Author

Thank you very much, issue finally resolved by a senior dev.

@github-project-automation github-project-automation bot moved this from Backlog to Done in workers-sdk Sep 16, 2024
@gregory
Copy link

gregory commented Oct 6, 2024

@DevAwais92 I've had the same issue but in local - turns out setting max_batch_timeout was preventing the consumer to work in local.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting reporter response Needs clarification or followup from OP bug Something that isn't working
Projects
Archived in project
Development

No branches or pull requests

3 participants