Sudden 500 errors after a routine deployment

For Workes & Pages, what is the name of the domain?

https://849c7f76.tapesearch.pages.dev/search

What is the error number?

500

What is the error message?

500 (Internal Server Error)

What is the issue or error you’re encountering

After a routine automated deployment to update sitemaps I found that all non-static pages (Edge function routes) returned a 500 error this morning. No changes had been made to the site code.

What steps have you taken to resolve the issue?

Checked the API/backend. All working fine and no errors on logs
Rolled back to a previous deployment and site is back online
Network tab in Dev Tools shows no activity
Checked build logs - no issues
All static pages (e.g. /about, /tos etc.) all work fine

What are the steps to reproduce the issue?

Build configuration
Build command: npx @cloudflare/next-on-pages@1
Build output: .vercel/output/static
Root directory:
Build comments: Enabled

Sounds like you had some change server side and something broke.
Check the logs: https://dash.cloudflare.com/?to=/:account/pages/view/:pages-project/:pages-deployment/functions

Here are the logs from my last successful deploy (the one I rolled back to): Cloudflare Deploy Log 2024-11-26 · GitHub

And here are the logs from this morning: Cloudflare Deploy Log 2024-12-02 · GitHub

As far as I can tell, they look identical bar @cloudflare/next-on-pages v1.13.5 → @cloudflare/next-on-pages v1.13.6 and wrangler 3.90.0 → wrangler 3.76.0 (older version?)

Have I missed anything else?

You want runtime logs (where it’s failing) not build logs. Go to the link I sent, navigate to your project and latest deployment and you can look at the logs as they come in

Ah thanks, I wasn’t aware of those logs. Here’s the output:

{
  "truncated": false,
  "executionModel": "stateless",
  "outcome": "ok",
  "scriptVersion": {
    "id": "365d389b-e594-4421-bdd1-bc94169e25aa"
  },
  "scriptName": "pages-worker--1825474-production",
  "diagnosticsChannelEvents": [],
  "exceptions": [],
  "logs": [
    {
      "message": [
        "Error: No such module \"__next-on-pages-dist__/functions/async_hooks\".\n  imported from \"__next-on-pages-dist__/functions/search.func.js\""
      ],
      "level": "error",
      "timestamp": 1733172174351
    }
  ],
  "eventTimestamp": 1733172174351,
  "event": {
    "request": {
      "url": "https://87a74257.tapesearch.pages.dev/search",
      "method": "GET",
      "headers": {
        "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
        "accept-encoding": "gzip, br",
        "accept-language": "en-GB,en-US;q=0.9,en;q=0.8",
        "cf-connecting-ip": "209.93.143.157",
        "cf-ipcountry": "GB",
        "cf-ray": "8ebe2569abcf6100",
        "cf-visitor": "{\"scheme\":\"https\"}",
        "connection": "Keep-Alive",
        "cookie": "REDACTED",
        "host": "87a74257.tapesearch.pages.dev",
        "priority": "u=0, i",
        "referer": "https://87a74257.tapesearch.pages.dev/",
        "sec-ch-ua": "\"Chromium\";v=\"130\", \"Google Chrome\";v=\"130\", \"Not?A_Brand\";v=\"99\"",
        "sec-ch-ua-mobile": "?0",
        "sec-ch-ua-platform": "\"Linux\"",
        "sec-fetch-dest": "document",
        "sec-fetch-mode": "navigate",
        "sec-fetch-site": "same-origin",
        "sec-fetch-user": "?1",
        "upgrade-insecure-requests": "1",
        "user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36",
        "x-forwarded-proto": "https",
        "x-real-ip": "209.93.143.157"
      },
      "cf": {
        "longitude": "-0.32950",
        "httpProtocol": "HTTP/3",
        "tlsCipher": "AEAD-AES128-GCM-SHA256",
        "continent": "EU",
        "asn": 6871,
        "clientAcceptEncoding": "gzip, deflate, br, zstd",
        "country": "GB",
        "verifiedBotCategory": "",
        "tlsClientAuth": {
          "certIssuerDNLegacy": "",
          "certIssuerSKI": "",
          "certSubjectDNRFC2253": "",
          "certSubjectDNLegacy": "",
          "certFingerprintSHA256": "",
          "certNotBefore": "",
          "certSKI": "",
          "certSerial": "",
          "certIssuerDN": "",
          "certVerified": "NONE",
          "certNotAfter": "",
          "certSubjectDN": "",
          "certPresented": "0",
          "certRevoked": "0",
          "certIssuerSerial": "",
          "certIssuerDNRFC2253": "",
          "certFingerprintSHA1": ""
        },
        "tlsClientHelloLength": "1764",
        "tlsExportedAuthenticator": {
          "clientFinished": "df634f64db0bd28429efee6496efda11a83e5798ed36b7b8e69aab5eb785766f",
          "clientHandshake": "6e034ac57cf587335305918ef29747dab082dd13f4954c6c8ff6ce3be01fd9d3",
          "serverHandshake": "3e8cf03daf2f4af77f44da67b9b505fc9dbb7487f7362ecdcc5d7ac76df3fdbc",
          "serverFinished": "81ada05d427c5e83ef236d448e1f31fec951b42b025d892bd4f09151d1eb54bd"
        },
        "tlsVersion": "TLSv1.3",
        "city": "Twickenham",
        "timezone": "Europe/London",
        "tlsClientExtensionsSha1": "6Mxi9vffT7vfn4fEAh1zs4e33ls=",
        "region": "England",
        "edgeRequestKeepAliveStatus": 1,
        "requestPriority": "",
        "latitude": "51.44300",
        "postalCode": "TW1",
        "tlsClientRandom": "XVy6QUwTDe3yRTd8EJlci/75kLaNbJOrxsL1XC0YUfw=",
        "regionCode": "ENG",
        "asOrganization": "Plusnet",
        "colo": "LHR",
        "pagesHostName": "87a74257.tapesearch.pages.dev",
        "botManagement": {
          "corporateProxy": false,
          "verifiedBot": false,
          "jsDetection": {
            "passed": false
          },
          "staticResource": false,
          "detectionIds": {},
          "score": 99
        }
      }
    },
    "response": {
      "status": 500
    }
  },
  "id": 2
}

Hi @WalshyMVP, I used the workaround in this thread, and it appears to have worked: Could not resolve "async_hooks" - #18 by Walshy

The thing is that my logs are saying that I was using next-on-pages version 1.13.6, so the problem doesn’t appear to be fixed as that thread suggests.