AB Testing worker question

Let say I have /old-product as the product page for my old product.

Now, I have a new product, it has the url /product.

I’d like to do AB testing on this new URL, split some portion of the traffic to the old product page, and let a portion of the requests go through to the actual new product page.

Using https://developers.cloudflare.com/workers/examples/ab-testing as the example source, and let’s pretend the worker is assigned to the /product url.


/product → TEST? → proxy to /product
CONTROL? → redirect to /old-product

My question is, when a request arrives at the worker, say it selects into the TEST scenario, it sets a cookie, and then responds with an await fetch(’/product’), but doesn’t that just return the request back at the worker? Where it will detect the cookie is present, but then respond with yet another wait fetch of the same URL? and hence, infinite loop?

So the gist of my question is, if a worker is defined to run on /foo, and in the worker, it fetches() that same path from the same host, will it cause an infinite loop? And if it does not, how does it work?