Error: Cannot perform I/O on behalf of a different request

HI guys

Newly here in cloudflare
I have a 2 webapp that i’ve deployed in cloudflare pages.
both of them facing same issues where when i capture the logs in the cloudflare pages streaming logs it says

Error: Cannot perform I/O on behalf of a different request. I/O objects (such as streams, request/response bodies, and others) created in the context of one request handler cannot be accessed from a different request's handler. This is a limitation of Cloudflare Workers which allows us to improve overall performance.

full logs:

{
  "outcome": "ok",
  "scriptName": "pages-worker--1910422-preview",
  "diagnosticsChannelEvents": [],
  "exceptions": [],
  "logs": [
    {
      "message": [
        "Error: Cannot perform I/O on behalf of a different request. I/O objects (such as streams, request/response bodies, and others) created in the context of one request handler cannot be accessed from a different request's handler. This is a limitation of Cloudflare Workers which allows us to improve overall performance."
      ],
      "level": "error",
      "timestamp": 1708268842457
    }
  ],
  "eventTimestamp": 1708268842450,
  "event": {
    "request": {
      "url": "https://dev.grorental-property-page.pages.dev/property/mekhi-wolf",
      "method": "GET",
      "headers": {
        "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8",
        "accept-encoding": "gzip",
        "accept-language": "en-GB,en;q=0.9",
        "cf-connecting-ip": "101.128.107.65",
        "cf-ipcountry": "ID",
        "cf-ray": "85772de94a8668db",
        "cf-visitor": "{\"scheme\":\"https\"}",
        "connection": "Keep-Alive",
        "host": "dev.grorental-property-page.pages.dev",
        "priority": "u=0, i",
        "referer": "https://dev.grorental-property-page.pages.dev/property",
        "sec-ch-ua": "\"Not A(Brand\";v=\"99\", \"Brave\";v=\"121\", \"Chromium\";v=\"121\"",
        "sec-ch-ua-mobile": "?0",
        "sec-ch-ua-platform": "\"Windows\"",
        "sec-fetch-dest": "document",
        "sec-fetch-mode": "navigate",
        "sec-fetch-site": "same-origin",
        "sec-fetch-user": "?1",
        "sec-gpc": "1",
        "upgrade-insecure-requests": "1",
        "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36",
        "x-forwarded-proto": "https",
        "x-real-ip": "101.128.107.65"
      },
      "cf": {
        "longitude": "106.99220",
        "latitude": "-6.23520",
        "tlsCipher": "AEAD-AES128-GCM-SHA256",
        "continent": "AS",
        "asn": 135478,
        "clientAcceptEncoding": "gzip, deflate, br",
        "country": "ID",
        "requestPriority": "",
        "tlsClientAuth": {
          "certIssuerDNLegacy": "",
          "certIssuerSKI": "",
          "certSubjectDNRFC2253": "",
          "certSubjectDNLegacy": "",
          "certFingerprintSHA256": "",
          "certNotBefore": "",
          "certSKI": "",
          "certSerial": "",
          "certIssuerDN": "",
          "certVerified": "NONE",
          "certNotAfter": "",
          "certSubjectDN": "",
          "certPresented": "0",
          "certRevoked": "0",
          "certIssuerSerial": "",
          "certIssuerDNRFC2253": "",
          "certFingerprintSHA1": ""
        },
        "verifiedBotCategory": "",
        "tlsExportedAuthenticator": {
          "clientFinished": "c8a6efbd2f6ec6251956beefb8c2e29d3a68f9200d01a2c292c23bcbf6bff681",
          "clientHandshake": "b929699ceb28654c315d874b3f41711f42700cecd57b8e37a0dbb3211fc53025",
          "serverHandshake": "1110a84e2ea7d612a1dde1fb18febf2021111a8e34fa0b869846f2560544d9f2",
          "serverFinished": "ea18951d56f4a97b290f72fc757677906fbfdb4c66765d136e9a523e986dbb3f"
        },
        "tlsVersion": "TLSv1.3",
        "city": "Bekasi",
        "timezone": "Asia/Jakarta",
        "tlsClientHelloLength": "560",
        "edgeRequestKeepAliveStatus": 1,
        "tlsClientRandom": "6h+cwM+eqD18sgzI5FhkBEib49p+nzYzlnpkw22pZiI=",
        "colo": "CGK",
        "region": "West Java",
        "httpProtocol": "HTTP/3",
        "regionCode": "JB",
        "asOrganization": "PT. Cyberindo Aditama",
        "pagesHostName": "dev.grorental-property-page.pages.dev",
        "botManagement": {
          "corporateProxy": false,
          "verifiedBot": false,
          "jsDetection": {
            "passed": false
          },
          "staticResource": false,
          "detectionIds": {},
          "score": 99
        }
      }
    },
    "response": {
      "status": 500
    }
  },
  "id": 1
}

this happening randomly usually when i click back or forward in the browser, and it’s happening in both my webapp and my user need to keep refreshing manually

In my case, I was trying to open a database connection at the module level, and then trying to reuse it in db functions. when I stopped reusing the db connection, the issue went away.
I do cache some other data I get via api calls, but did not have any issue with that. Guess workers can serve multipe requests, and is not allowed to keep I/O related state.