Does fetch() inside a worker makes recursive loop calls to the route?


I studied the documentation about the fetch api call

to find a answer to my question about possible unwanted recursive loop calls when using fetch inside workers but somehow the documentation does not answer my question.

If i have the following route for my test worker script


worker: static.js

and inside of my worker i call fetch() with the following url argument as a failover because let’s say the static content was not found inside the kv DB and for this a fetch to the original server with the same url needs to be maked.

response = fetch('')

will this cause a new call to my worker script as it makes a new request that match the defined route for the test worker script or will the fetch call inside the worker make a direct call to the origin server ignoring the route ?

I could not find anywhere any Answer.

I ask this becouse when i debug such a test case inside the worker Editor
the fetch api call inside the test worker returns always a 200 response even when the url point to a 404 non existent resource on the original server !
This is very Strange and should not happen and i ask me why fetch returns 200 OK even the resource does not exist on the original server !

I guess this indicate that fetch indeed inside a worker script makes recursive loop calls to the defined route but then how can the orginal resource be fetched from inside the worker script ?

Thanks in advance for any helpfull answers !

It will go to the origin. You can’t call a worker of the same zone from within a worker running on that specific zone.


Thank you very much matteo for your helpfull clarification and your fast answer !

WIll have to isolate the Problem more then why a fetch to a non existent 404 resource on the original server from inside a worker in the Online Editor when using the original url instead of the dev subdomain dev url as a test url gives me a 200 OK instead of a 404.

Must be then guess related to the Online Debug Editor everytime the original url is used as a test url instead of the dev subdomain that makes a fetch in worker script return 200 when no resource exist.

Will have to do more debug work.
Thanks a lot !