neondatabase / serverless

Connect to Neon PostgreSQL from serverless/worker/edge functions
https://www.npmjs.com/package/@neondatabase/serverless
MIT License
318 stars 11 forks source link

Cloudflare Pages with Functions yields "NeonDbError: Error connecting to database: Reflect.get called on non-object" #58

Closed Gregoor closed 2 months ago

Gregoor commented 5 months ago

Steps to reproduce

  1. use @neondatabase/serverless on cloudflare with pages & functions
  2. get the error above and have all functions 500

Environment

Cloudflare with Nextjs

Logs, links

full log ```json { "outcome": "ok", "scriptName": "pages-worker--1720533-production", "diagnosticsChannelEvents": [], "exceptions": [], "logs": [ { "message": [ "NeonDbError: Error connecting to database: Reflect.get called on non-object" ], "level": "error", "timestamp": 1706110007697 } ], "eventTimestamp": 1706110007696, "event": { "request": { "url": "https://bremse.pages.dev/api/plz?strasse=hochstr&nummer=undefined", "method": "GET", "headers": { "accept": "*/*", "accept-encoding": "gzip", "accept-language": "en-US,en;q=0.9", "cache-control": "no-cache", "cf-connecting-ip": "2003:d4:6f37:c300:2897:8334:a929:43a2", "cf-ipcountry": "DE", "cf-ray": "84a94bfc18a762e6", "cf-visitor": "{\"scheme\":\"https\"}", "connection": "Keep-Alive", "dnt": "1", "host": "bremse.pages.dev", "pragma": "no-cache", "priority": "u=1, i", "referer": "https://bremse.pages.dev/", "sec-ch-ua": "\"Not_A Brand\";v=\"8\", \"Chromium\";v=\"120\"", "sec-ch-ua-mobile": "?0", "sec-ch-ua-platform": "\"macOS\"", "sec-fetch-dest": "empty", "sec-fetch-mode": "cors", "sec-fetch-site": "same-origin", "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36", "x-forwarded-proto": "https", "x-real-ip": "2003:d4:6f37:c300:2897:8334:a929:43a2" }, "cf": { "longitude": "13.41640", "latitude": "52.47460", "tlsCipher": "AEAD-AES128-GCM-SHA256", "continent": "EU", "asn": 3320, "clientAcceptEncoding": "gzip, deflate, br", "country": "DE", "isEUCountry": "1", "tlsClientAuth": { "certIssuerDNLegacy": "", "certIssuerSKI": "", "certSubjectDNRFC2253": "", "certSubjectDNLegacy": "", "certFingerprintSHA256": "", "certNotBefore": "", "certSKI": "", "certSerial": "", "certIssuerDN": "", "certVerified": "NONE", "certNotAfter": "", "certSubjectDN": "", "certPresented": "0", "certRevoked": "0", "certIssuerSerial": "", "certIssuerDNRFC2253": "", "certFingerprintSHA1": "" }, "postalCode": "12049", "tlsExportedAuthenticator": { "clientFinished": "81fb69d8a822eca7080263409101d74ecc3f6870e376607cc586fe86d5bfcd2e", "clientHandshake": "acedab6c6ad19fbd773b6a335f1a669f5ef9391b83f5b54a88b87d46d31796b9", "serverHandshake": "fb54d419fd965b985e49ab4097356dcfed48570c2d3711ddd1fe6887d4ce565e", "serverFinished": "b7eaf628a540a27ba7f10e4d0cacd1fadb0dd44d1c05eb7cb42599f5796b76d9" }, "tlsVersion": "TLSv1.3", "city": "Berlin", "timezone": "Europe/Berlin", "verifiedBotCategory": "", "edgeRequestKeepAliveStatus": 1, "requestPriority": "", "colo": "HAM", "httpProtocol": "HTTP/3", "region": "Land Berlin", "regionCode": "BE", "asOrganization": "Deutsche Telekom AG", "pagesHostName": "bremse.pages.dev", "botManagement": { "corporateProxy": false, "verifiedBot": false, "jsDetection": { "passed": false }, "staticResource": false, "detectionIds": {}, "score": 99 } } }, "response": { "status": 500 } }, "id": 7 } ```
jawj commented 5 months ago

Thanks for raising an issue.

I have some projects where @neondatabase/serverless is working on Cloudflare Pages, so it would be helpful if you could provide a repo (or commands for setting up a project) that shows the problem.

janpio commented 5 months ago

This might be related: https://github.com/cloudflare/next-on-pages/issues/499 Shows a problem that only happens when using @cloudflare/next-on-pages, and links to other issues on Cloudflare's side.

jawj commented 4 months ago

It looks as if this may have been fixed by a recent change to Workers: https://github.com/cloudflare/workerd/issues/1513#issuecomment-1936275341

@Gregoor Is your problem resolved?

Gregoor commented 4 months ago

Sorry, I don't have the project anymore as we jumped ship somewhere else. Will post here again if I try it again

jawj commented 4 months ago

Sorry to hear that. Thank you.