I am trying to test locally getting a file from R2 bucket which i added via dashboard

I created a worker cron job and am testing locally via wrangler dev --test-scheduled. calling await env.MY_BUCKET.get('myfile.json'); returns null even though the file exists in my R2 bucket dashboard. Why is this the case?
29 Replies
Chaika
Chaika•4mo ago
default dev is local/all simulated, have to use --remote if you want to use remote resources
f8
f8•4mo ago
Is there way to manually add files to r2 simulated bucket via dashboard? It wont let me use production one: In development, you should use a separate r2 bucket than the one you'd use in production. Please create a new r2 bucket with "wrangler r2 bucket create <name>" and add its name as preview_bucket_name to the r2_buckets "MY_BUCKET" in your wrangler.toml
Chaika
Chaika•4mo ago
The whole thing with the simulated bucket is that it's all local so nothing in the dashboard is going to be able to touch your local resources
f8
f8•4mo ago
Thanks Im getting a 504 Gateway Time-out cloudflare workers for my cron job at 120214ms. I have no cpu limit set and paying for the standard plan
Walshy
Walshy•4mo ago
What are you doing in the Worker?
f8
f8•4mo ago
Making hundreds of requests to a third party api which im using that fetched data from those api requests and putting them in a json which at end i will push to R2
Walshy
Walshy•4mo ago
and where you seeing the 504? i'm not surprised you see it if you fetch anything - after 100 seconds (which you're doing 120 total) it'll return that yeah so my guess - that third party api is timing out you can debug to confirm but that's my theory
f8
f8•4mo ago
Getting 504 in console after running npx wrangler dev --test-scheduled --remote I ran this script locally though and it worked fine Would cloudflare not timeout ever in this case?
Walshy
Walshy•4mo ago
I'm not sure what you mean
f8
f8•4mo ago
Say the third party api wasn't timing out, what else could cause the 504 gateway timeout on cloudflare's side for this cronjob
Walshy
Walshy•4mo ago
I wonder if --test-scheduled is essentially doing a http request and that's why it's timing out too since your Worker isn't responding in 100 seconds - timeout
f8
f8•4mo ago
Gotcha. It's always timing out around 122411ms as well
Walshy
Walshy•4mo ago
I'd need to check the code and see what --test-scheduled is doing but 504 in cf == no response for 100 seconds (or whatever your configured limit is - for you it'll very likely be 100 seconds)
f8
f8•4mo ago
But it seems to give error after 122 seconds of running
Walshy
Walshy•4mo ago
yeah the 20 seconds is not that relevant, bunch of reasons there could be 20 more seconds hell you could have 650 seconds and it still be this limit it's a long explanation for why
Want results from more Discord servers?
Add your server