Error Lens is the extension I have on vs code that makes it a bit easier to see these errors for me at least
.forEachthis.env = env in the constructor to be able to call bindings from methods, then tried to send a last message to a queue right after calling this.state.storage.deleteAll(), but it turns out calling deleteAll() also deletes the current memory and references of the object (not just storage), so the binding was lost. The error message is a bit confusing though - it made me believe the error was on CF's side (checked status page as well).A batch can contain up to 100 messages, though items are limited to 128 KB each, and the total size of the array cannot exceed 256 KB.https://developers.cloudflare.com/queues/platform/javascript-apis/#queue
waitUntil unless you are actively logging[[kv_namespaces]]
binding = "AIS_ALL_TRANSACTIONS"
id = "xxxxx" <=I have the correct Id in here
[[queues.consumers]]
queue = "my-q" <=Correct queue here as well
# Optional: Configure batching and retries: https://developers.cloudflare.com/queues/learning/batching-retries/
# max_batch_size = 10 //The maximum number of messages to deliver before the timeout
# max_batch_timeout = 30 //default is 5 seconds
# max_retries = 10 //default to 3
# all dead transactions go to the following dead letter queue
dead_letter_queue = "transaction-dead-q" Error Lens.forEachthis.env = envthis.state.storage.deleteAll()deleteAll()export async fetch(request: Request, env: Environment, ctx: ExecutionContext) {
const response = await fetch(someUrl);
const objectsStream = response.body!.getReader()
.pipeThrough(new TextDecoderStream())
.pipeThrough(new CSVParserStream());
const enqueue = async () => {
for await (const objects of take(100, objectsStream)) {
await env.MY_QUEUE.sendBatch(objects.map(object => ({
body: object,
contentType: "json",
})));
}
};
ctx.waitUntil(
enqueue()
.then(() => {
console.log("Success");
})
.catch(console.error)
);
return new Response("OK");
}