Issue With Worker-To-Worker HTTPS request

Looks like there’s a worker-to-worker fetch issue and here’s how to reproduce it.

  1. Create two workers, worker1 and worker2.
  2. Use the default “hello world” code for worker2.
  3. Use the following code for worker1 (changing worker2 to the actual domain name for worker2).
addEventListener('fetch', event => {
  event.respondWith(handleRequest(event.request))
})

async function handleRequest(request) {
  const url = new URL(request.url);
  let originUrl;
  switch (url.searchParams.get('test')) {
    case '0': originUrl = 'https://www.cloudflare.com/robots.txt'
    case '1':
      originUrl = originUrl || 'https://worker2/';
      return fetch(originUrl)
    default:
      return new Response(null, {status: 403})
  }
}
  1. Go to https://worker1/?test=0 and there’s no problem.
  2. Go to https://worker1/?test=1 in a browser (not in the sandbox) and you’ll get an “Error 522” page after a long timeout period.