Cloudflare worker to r2 storage after three attempts accessing the same picture failed

currently i tried to use worker to access my R2, the funny things happened when i tried to access the same picture in three times or fourth times in a row using refreshed button on the browser.
It just said Uncaught (in promise) Error: get: We encountered an internal error. Please try again. (10001)

this is my code

     export default {
        async fetch(request: Request, env: Env): Promise<Response> {
	console.log("running workers")
	const API_KEY_HEADER = "X-API-KEY";
	const psk = request.headers.get(API_KEY_HEADER);

	const url = new URL(request.url);
	console.log(request.headers);
	const key = url.pathname.slice(1);

	switch (request.method) {
		case 'PUT':
			if (psk!==env.token){
				return new Response("token not the same",{status:403})
			}
			await env.ecogroovi.put(key, request.body);
			return new Response(`Put ${key} successfully!`);
		case 'GET':
			console.log("Get object")

			const object = await env.ecogroovi.get(key);

			if (!object || !object.body) {
				return new Response('Object Not Found', { status: 404 });
			}
			console.log("write headers")
			const headers = new Headers();
			object.writeHttpMetadata(headers);
			headers.set('etag', object.httpEtag);



			console.log("return object")
			return new Response(object.body, {
				headers,
			});





		case 'DELETE':
			if (psk!==env.token){
				return new Response("token not the same",{status:403})
			}
			await env.ecogroovi.delete(key);
			return new Response('Deleted!');

		default:
			return new Response('Method Not Allowed', {
				status: 405,
				headers: {
					Allow: 'PUT, GET, DELETE',
				},
			});
	}
},
};

The code was copied from Cloudflare example

The error happened when worker tried to get object. I put some gif bellow

errorcloud

its there any limitation on the Cloudflare worker access to R2?

Anyone can help?

Thanks

Arif marendra

I have this problem too, both access via Worker and Cloudflare Public (xxx.r2.dev) sometime error 500

I am seeing the same thing when connecting to R2 through a Worker also. These errors started just after 3pm (GMT+1) on October 28th.

The error that I am seeing is:

get: We encountered an internal error. Please try again. (10001)

I created a ticket yesterday shortly after this started happening but I have not recieved an update yet.

hi @dave92 , let us know if Cloudflare support already answered your ticket.

many thanks

Cloudflare have acknowledge the issue now, see here: https://www.cloudflarestatus.com/incidents/zmz9n135np44