Workers randomly throwing 502 "bad gateway" responses while developing locally with `--remote`

There are so many seemingly random errors thrown by workers while developing locally that the experience can be a drag (I've raised most of these in previous threads here.)

Today, I've started getting 502s every now and then. When this happens, I have no choice but to restart the Worker and then the exact same request succeeds.

In case it's relevant, I'm developing with the
--remote
flag for reasons that are outside this topic.

Error on remote worker: ParseError: Received a malformed response from the API

      at fetchInternal
  (C:\Users\termi\Sync\dev\projects\***\node_modules\wrangler\wrangler-dist\cli.js:119376:11)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async fetchResult
  (C:\Users\termi\Sync\dev\projects\***\node_modules\wrangler\wrangler-dist\cli.js:119504:16)
      at async createPreviewToken
  (C:\Users\termi\Sync\dev\projects\***\node_modules\wrangler\wrangler-dist\cli.js:157913:29)
      at async createWorkerPreview
  (C:\Users\termi\Sync\dev\projects\***\node_modules\wrangler\wrangler-dist\cli.js:157934:17)
      at async start
  (C:\Users\termi\Sync\dev\projects\***\node_modules\wrangler\wrangler-dist\cli.js:158503:34)
  {
    text: 'Received a malformed response from the API',
    notes: [
      {
        text: '<html>\r\n' +
          '<head><title>502 Bad Gateway</title></head>\r\n' +
          '<body>\r\n' +
          '<center><h1>502 Bad Gateway</h1></cente... (length = 155)'
      },
      {
        text: 'POST
  /accounts/8701fe61c0686bad57c64dd62d3dc16b/workers/scripts/hlp-v2-back-dev/edge-preview -> 502 Bad
  Gateway'
      }
    ],
    location: undefined,
    kind: 'error'
  }


Nothing in my app throws this error explicitly or outputs HTML, so I assume this response is coming directly from CF.

Any thoughts here? Thank you.
Was this page helpful?