Worker throws "Network connection lost."

Hello,

Sometimes my worker throws an exception “Network connection lost.”, I got it in the wrangler tail:

{"outcome":"ok","scriptName":null,"exceptions":[{"name":"Error","message":"Network connection lost.","timestamp":1626639666788}],"logs":[{"message":["Using cache: False"],"level":"log","timestamp":1626639666745}],"eventTimestamp":1626639666740,"event":{"request":{"url":"MY_URL","method":"GET","headers":{"accept":"image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, image/png, */*","accept-charset":"iso-8859-1,utf-8;q=0.9,*;q=0.1","accept-encoding":"gzip","accept-language":"en","cf-connecting-ip":"CLIENT_IP","cf-int-smart-routing-table-id":"100","cf-ipcountry":"US","cf-ray":"REDACTED","cf-visitor":"{\"scheme\":\"http\"}","connection":"Keep-Alive","cookie":"REDACTED","host":"MY_URL","pragma":"no-cache","user-agent":"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)","x-forwarded-proto":"http","x-real-ip":"CLIENT_IP"},"cf":{"clientTcpRtt":1,"longitude":"REDACTED","httpProtocol":"HTTP/1.1","tlsCipher":"","continent":"NA","asn":REDACTED,"country":"US","tlsClientAuth":{"certIssuerDNLegacy":"","certIssuerSKI":"","certSubjectDNRFC2253":"","certSubjectDNLegacy":"","certFingerprintSHA256":"","certNotBefore":"","certSKI":"","certSerial":"","certIssuerDN":"","certVerified":"NONE","certNotAfter":"","certSubjectDN":"","certPresented":"0","certRevoked":"0","certIssuerSerial":"","certIssuerDNRFC2253":"","certFingerprintSHA1":""},"tlsVersion":"","colo":"IAD","timezone":"America/New_York","region":"Virginia","requestPriority":"","latitude":"REDACTED","city":"Ashburn","regionCode":"VA","postalCode":"REDACTED","metroCode":"REDACTED","edgeRequestKeepAliveStatus":1}}}}

This worker fetches the content from AWS S3 bucket, I have added a catch on fetch, but the code on catch is not executed, looks like it’s an error in the CloudFlare or client side.

request = await fetch(urlToRequest,{
      method: "GET",
      redirect: "follow"
    }).catch(error => {
      const message = `urlToRequest: ${urlToRequest}, Error from fetch: ${error}`
      console.log(`There has been a problem with fetch operation! ${message}`);
      event.waitUntil(logDatadog("fetchError", message, "null"));
    });

Can someone help me? Thanks

1 Like

I’m having the same issue. Do we know if that’s an issue with Cloudflare itself?

I’m having the same issue as well in the past couple days. It’s happening when my cron job runs the script.

Working for me now…I guess it was cloudflare bugging out? Working for you jmartins?

Yep, working for me now too. Looks like an issue with their cron jobs.

1 Like

The same issue today.

same issue today. many times.

When I asked the service team about this problem before, they said it was a client-side problem, but I wonder how they will respond after today’s failure

now it’s clear this issue from worker internal error

Same issue today

Any help?

Something new about this issue? I’m getting thousands of these errors per month.

It’s the same here; I often get the message Error: Network connection lost. I think the problem came from CF.