Compatibility flags for PosgreSQL

I am trying to build and deploy SvelteKit page with enabled flags: nodejs_compat or nodejs_compat_v2 https://developers.cloudflare.com/workers/configuration/compatibility-dates/#compatibility-flags I am using Drizzle connector, but seems I run always into node compatibility issues, which are present on native postgres.js also. Connectors are present in Hyperdrive: https://developers.cloudflare.com/hyperdrive/configuration/connect-to-postgres/#supported-drivers Source code: https://github.com/bchainhub/dapp-sveltekit-boilerplate/tree/update/contrib-13 My questions: Q1: Do I need to upgrade to paid plan for Node.js features support? (I am aware of Hyperdrive included in Paid plan) Q2: What should I change to make Node.js API working on my Pages deployment? Some of errors I am getting while deployment:
✘ [ERROR] Could not resolve "node:stream"
node_modules/postgres/cf/src/large.js:1:import Stream from 'node:stream'
The package "node:stream" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.

error during build:
Error: Build failed with 8 errors:
node_modules/postgres/cf/polyfills.js:1:29: ERROR: Could not resolve "node:events"
node_modules/postgres/cf/polyfills.js:2:23: ERROR: Could not resolve "node:buffer"
node_modules/postgres/cf/src/bytes.js:1:23: ERROR: Could not resolve "node:buffer"
node_modules/postgres/cf/src/connection.js:1:23: ERROR: Could not resolve "node:buffer"
node_modules/postgres/cf/src/connection.js:6:19: ERROR: Could not resolve "node:stream"
✘ [ERROR] Could not resolve "node:stream"
node_modules/postgres/cf/src/large.js:1:import Stream from 'node:stream'
The package "node:stream" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.

error during build:
Error: Build failed with 8 errors:
node_modules/postgres/cf/polyfills.js:1:29: ERROR: Could not resolve "node:events"
node_modules/postgres/cf/polyfills.js:2:23: ERROR: Could not resolve "node:buffer"
node_modules/postgres/cf/src/bytes.js:1:23: ERROR: Could not resolve "node:buffer"
node_modules/postgres/cf/src/connection.js:1:23: ERROR: Could not resolve "node:buffer"
node_modules/postgres/cf/src/connection.js:6:19: ERROR: Could not resolve "node:stream"
- page: core-dapp.pages.dev - deployment: 580ce1e I checked the examples here also: https://developers.cloudflare.com/hyperdrive/examples/
10 Replies
vytskalt
vytskalt2mo ago
i just ran into this exact same error (using sveltekit + postgres.js). were you able to resolve it?
Rastislav₡ore
Rastislav₡ore2mo ago
@vytskalt so far no solution. Seems this is serious bug on side of Cloudflare. I am trying to resolve with Drizzle ORM but same issues. I will update here if some news will occur. @Community Champion should I report bug? If yes, where?
andrew_nyr
andrew_nyr2mo ago
?pings
Flare
Flare2mo ago
Please do not ping community members for non-moderation reasons. Doing so will not solve your issue faster and will make people less likely to want to help you.
Rastislav₡ore
Oh sorry, didn't know. I will found out myself. @vytskalt Sent to support. When I will get any reply, I will reveal solution here. Similar error related for Next.js is here: https://discord.com/channels/595317990191398933/1287862192712192113 One additional note to the topic: - I have paid pages/workers plan - Hyperdrive is available for me No other updates so far about the topic.
Register
Register3w ago
Im having this exact issue too after implementing svelte, but im not using sveltekit
⛅️ wrangler 3.79.0
-------------------

X [ERROR] Could not resolve "@base/ResponseCode"

api/playground/token.ts:2:29:
2 │ import { ResponseCode } from "@base/ResponseCode";
╵ ~~~~~~~~~~~~~~~~~~~~

You can mark the path "@base/ResponseCode" as external to exclude it from the bundle, which will remove this error.



X [ERROR] Failed to build Functions at ./functions.
⛅️ wrangler 3.79.0
-------------------

X [ERROR] Could not resolve "@base/ResponseCode"

api/playground/token.ts:2:29:
2 │ import { ResponseCode } from "@base/ResponseCode";
╵ ~~~~~~~~~~~~~~~~~~~~

You can mark the path "@base/ResponseCode" as external to exclude it from the bundle, which will remove this error.



X [ERROR] Failed to build Functions at ./functions.
My ResponseCode.ts
export enum ResponseCode {
OK = 200,
Created = 201,
NoContent = 204,
BadRequest = 400,
Unauthorized = 401,
Forbidden = 403,
NotFound = 404,
MethodNotAllowed = 405,
Conflict = 409,
InternalServerError = 500,
NotImplemented = 501,
BadGateway = 502,
ServiceUnavailable = 503,
}
export enum ResponseCode {
OK = 200,
Created = 201,
NoContent = 204,
BadRequest = 400,
Unauthorized = 401,
Forbidden = 403,
NotFound = 404,
MethodNotAllowed = 405,
Conflict = 409,
InternalServerError = 500,
NotImplemented = 501,
BadGateway = 502,
ServiceUnavailable = 503,
}
and the token.ts file thats throwing the error
import EventContext from "@base/EventContext";
import { ResponseCode } from "@base/ResponseCode";
import { ChaCha20Poly1305 } from "@stablelib/chacha20poly1305";
import { randomBytes } from "@stablelib/random";
import EventContext from "@base/EventContext";
import { ResponseCode } from "@base/ResponseCode";
import { ChaCha20Poly1305 } from "@stablelib/chacha20poly1305";
import { randomBytes } from "@stablelib/random";
It specifically targets the ResponseCode.ts file for some reason and I have no idea why EventContext.ts is in the same directory as @base
Rastislav₡ore
I think the issue is not related to framework, because I am aware of issues for React also. You may be in same category as us. I am still waiting for support team to answer. Seems no really priority to them. I will recommend you will raise support ticket as well, it may be faster answer for you. I will appreciate sharing any feedback from you @Register Thank you for contributing to thread.
Register
Register2w ago
Actually we fixed it
Register
Register2w ago
It was an issue with our tsconfig
No description
Rastislav₡ore
Reply from the Cloudflare support: Please consider the following recommendations: 1. Change the NODE_VERSION to v18. 2. Set the compatibility date to the current date.
Want results from more Discord servers?
Add your server