drizzle-team / drizzle-orm

Headless TypeScript ORM with a head. Runs on Node, Bun and Deno. Lives on the Edge and yes, it's a JavaScript ORM too 😅
https://orm.drizzle.team
Apache License 2.0
24.54k stars 643 forks source link

[BUG]: New critical Build error drizzle 0.35.0 deploying on Cloudflare #3137

Closed Jumaron closed 1 month ago

Jumaron commented 1 month ago

What version of drizzle-orm are you using?

0.35.0

What version of drizzle-kit are you using?

0.26.1

Describe the Bug

Since updating from 0.34.1 to 0.35.0 I encounter this error when i try to build the project locally or on Cloudflare itself, on version 0.34.1 the issue does not exist.

Using @sveltejs/adapter-cloudflare X [ERROR] Could not resolve "fs"

node_modules/@neon-rs/load/dist/index.js:28:32:
  28 │ const fs = __importStar(require("fs"));
     ╵                                 ~~~~

Cannot use "fs" when deploying to Cloudflare.

X [ERROR] Could not resolve "child_process"

node_modules/detect-libc/lib/detect-libc.js:6:29:
  6 │ const childProcess = require('child_process');
    ╵                              ~~~~~~~~~~~~~~~

Cannot use "child_process" when deploying to Cloudflare.

X [ERROR] Could not resolve "fs"

node_modules/detect-libc/lib/filesystem.js:6:19:
  6 │ const fs = require('fs');
    ╵                    ~~~~

Cannot use "fs" when deploying to Cloudflare.

Expected behavior

No response

Environment & setup

No response

AndriiSherman commented 1 month ago

Could you share some repro example, so we can try it ourselves?

Jumaron commented 1 month ago

Hey Andrii, https://github.com/Jumaron/DrizzleBug this should be as raw as it gets. But, installing default Sveltkit with svelte 5 and using the newest drizzle Version with the Cloudflare sveltekit adapter should be enough to trigger it.

Reason is that the filesystem reads like this for example: require('fs') are not directly supported in Cloudflares worker environment.

efkann commented 1 month ago

I also got the same error when deploying my Remix + Turso + DrizzleORM app to Cloudflare Pages.

By following the steps described here https://developers.cloudflare.com/workers/databases/native-integrations/turso/

Downgrading to 0.34.1 fixed it.

Jumaron commented 1 month ago

Most likely effects all deployments to Cloudflare Pages.

thibaultleouay commented 1 month ago

We had the same here

https://github.com/openstatusHQ/openstatus/pull/1048

Upgrading to 0.35 fails to build a next app

here's the build log

 pnpm build

> web@1.0.0 build /Users/thibaultleouay/git/openstatus/apps/web
> next build

  ▲ Next.js 14.2.15
  - Environments: .env
  - Experiments (use with caution):
    · swrDelta

   Creating an optimized production build ...
(node:49785) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
Generated 56 documents in .contentlayer
Failed to compile.

../../node_modules/.pnpm/@libsql+client@0.14.0_bufferutil@4.0.8_utf-8-validate@6.0.4/node_modules/@libsql/client/README.md
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> <p align="center">
|   <a href="https://docs.turso.tech/sdk/ts/quickstart">
|     <img alt="Turso + TypeScript" src="https://github.com/tursodatabase/libsql-client-ts/assets/950181/5d3a2693-75f9-4c56-9107-8ccaa96785fd" width="1000">

Import trace for requested module:
../../node_modules/.pnpm/@libsql+client@0.14.0_bufferutil@4.0.8_utf-8-validate@6.0.4/node_modules/@libsql/client/README.md
../../node_modules/.pnpm/libsql@0.4.5/node_modules/@libsql/ ../../node_modules/.pnpm/node_modules/@libsql/ ../../node_modules/.pnpm/node_modules/@libsql/ ../../node_modules/.pnpm/libsql@0.4.5/node_modules/@libsql/ ../../node_modules/.pnpm/node_modules/@libsql/ ../../node_modules/.pnpm/node_modules/@libsql/ sync ^\.\/.*$
../../node_modules/.pnpm/libsql@0.4.5/node_modules/libsql/index.js
../../node_modules/.pnpm/@libsql+client@0.14.0_bufferutil@4.0.7_utf-8-validate@6.0.3/node_modules/@libsql/client/lib-esm/sqlite3.js
../../node_modules/.pnpm/drizzle-orm@0.35.0_@cloudflare+workers-types@4.20240512.0_@libsql+client@0.14.0_bufferutil@4._nzyd4orv5kma6pu4j3txyc6j4y/node_modules/drizzle-orm/libsql/driver.js
../../node_modules/.pnpm/drizzle-orm@0.35.0_@cloudflare+workers-types@4.20240512.0_@libsql+client@0.14.0_bufferutil@4._nzyd4orv5kma6pu4j3txyc6j4y/node_modules/drizzle-orm/libsql/index.js
../../packages/db/src/db.ts
./src/app/status-page/[domain]/_components/actions.ts

../../node_modules/.pnpm/@libsql+client@0.14.0_bufferutil@4.0.8_utf-8-validate@6.0.4/node_modules/@libsql/client/README.md
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> <p align="center">
|   <a href="https://docs.turso.tech/sdk/ts/quickstart">
|     <img alt="Turso + TypeScript" src="https://github.com/tursodatabase/libsql-client-ts/assets/950181/5d3a2693-75f9-4c56-9107-8ccaa96785fd" width="1000">

Import trace for requested module:
../../node_modules/.pnpm/@libsql+client@0.14.0_bufferutil@4.0.8_utf-8-validate@6.0.4/node_modules/@libsql/client/README.md
../../node_modules/.pnpm/libsql@0.4.5/node_modules/@libsql/ ../../node_modules/.pnpm/node_modules/@libsql/ ../../node_modules/.pnpm/node_modules/@libsql/ ../../node_modules/.pnpm/libsql@0.4.5/node_modules/@libsql/ ../../node_modules/.pnpm/node_modules/@libsql/ ../../node_modules/.pnpm/node_modules/@libsql/ sync ^\.\/.*$
../../node_modules/.pnpm/libsql@0.4.5/node_modules/libsql/index.js
../../node_modules/.pnpm/@libsql+client@0.14.0_bufferutil@4.0.7_utf-8-validate@6.0.3/node_modules/@libsql/client/lib-esm/sqlite3.js
../../node_modules/.pnpm/drizzle-orm@0.35.0_@cloudflare+workers-types@4.20240512.0_@libsql+client@0.14.0_bufferutil@4._nzyd4orv5kma6pu4j3txyc6j4y/node_modules/drizzle-orm/libsql/driver.js
../../node_modules/.pnpm/drizzle-orm@0.35.0_@cloudflare+workers-types@4.20240512.0_@libsql+client@0.14.0_bufferutil@4._nzyd4orv5kma6pu4j3txyc6j4y/node_modules/drizzle-orm/libsql/index.js
../../packages/db/src/db.ts
./src/app/api/internal/email/route.ts

../../node_modules/.pnpm/@libsql+darwin-arm64@0.4.5/node_modules/@libsql/darwin-arm64/README.md
Module parse failed: Unexpected character ' ' (1:1)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> # `@libsql/darwin-arm64`
| 
| Prebuilt binary package for `libsql` on `darwin-arm64`.

Import trace for requested module:
../../node_modules/.pnpm/@libsql+darwin-arm64@0.4.5/node_modules/@libsql/darwin-arm64/README.md
../../node_modules/.pnpm/libsql@0.4.5/node_modules/@libsql/ ../../node_modules/.pnpm/node_modules/@libsql/ ../../node_modules/.pnpm/node_modules/@libsql/ ../../node_modules/.pnpm/libsql@0.4.5/node_modules/@libsql/ ../../node_modules/.pnpm/node_modules/@libsql/ ../../node_modules/.pnpm/node_modules/@libsql/ sync ^\.\/.*$
../../node_modules/.pnpm/libsql@0.4.5/node_modules/libsql/index.js
../../node_modules/.pnpm/@libsql+client@0.14.0_bufferutil@4.0.7_utf-8-validate@6.0.3/node_modules/@libsql/client/lib-esm/sqlite3.js
../../node_modules/.pnpm/drizzle-orm@0.35.0_@cloudflare+workers-types@4.20240512.0_@libsql+client@0.14.0_bufferutil@4._nzyd4orv5kma6pu4j3txyc6j4y/node_modules/drizzle-orm/libsql/driver.js
../../node_modules/.pnpm/drizzle-orm@0.35.0_@cloudflare+workers-types@4.20240512.0_@libsql+client@0.14.0_bufferutil@4._nzyd4orv5kma6pu4j3txyc6j4y/node_modules/drizzle-orm/libsql/index.js
../../packages/db/src/db.ts
./src/app/status-page/[domain]/_components/actions.ts

../../node_modules/.pnpm/@libsql+darwin-arm64@0.4.5/node_modules/@libsql/darwin-arm64/README.md
Module parse failed: Unexpected character ' ' (1:1)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> # `@libsql/darwin-arm64`
| 
| Prebuilt binary package for `libsql` on `darwin-arm64`.

Import trace for requested module:
../../node_modules/.pnpm/@libsql+darwin-arm64@0.4.5/node_modules/@libsql/darwin-arm64/README.md
../../node_modules/.pnpm/libsql@0.4.5/node_modules/@libsql/ ../../node_modules/.pnpm/node_modules/@libsql/ ../../node_modules/.pnpm/node_modules/@libsql/ ../../node_modules/.pnpm/libsql@0.4.5/node_modules/@libsql/ ../../node_modules/.pnpm/node_modules/@libsql/ ../../node_modules/.pnpm/node_modules/@libsql/ sync ^\.\/.*$
../../node_modules/.pnpm/libsql@0.4.5/node_modules/libsql/index.js
../../node_modules/.pnpm/@libsql+client@0.14.0_bufferutil@4.0.7_utf-8-validate@6.0.3/node_modules/@libsql/client/lib-esm/sqlite3.js
../../node_modules/.pnpm/drizzle-orm@0.35.0_@cloudflare+workers-types@4.20240512.0_@libsql+client@0.14.0_bufferutil@4._nzyd4orv5kma6pu4j3txyc6j4y/node_modules/drizzle-orm/libsql/driver.js
../../node_modules/.pnpm/drizzle-orm@0.35.0_@cloudflare+workers-types@4.20240512.0_@libsql+client@0.14.0_bufferutil@4._nzyd4orv5kma6pu4j3txyc6j4y/node_modules/drizzle-orm/libsql/index.js
../../packages/db/src/db.ts
./src/app/api/internal/email/route.ts

../../node_modules/.pnpm/@libsql+hrana-client@0.7.0_bufferutil@4.0.7_utf-8-validate@6.0.3/node_modules/@libsql/hrana-client/LICENSE
Module parse failed: Unexpected token (1:4)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> MIT License
| 
| Copyright 2023 the sqld authors

Import trace for requested module:
../../node_modules/.pnpm/@libsql+hrana-client@0.7.0_bufferutil@4.0.7_utf-8-validate@6.0.3/node_modules/@libsql/hrana-client/LICENSE
../../node_modules/.pnpm/libsql@0.4.5/node_modules/@libsql/ ../../node_modules/.pnpm/node_modules/@libsql/ ../../node_modules/.pnpm/node_modules/@libsql/ ../../node_modules/.pnpm/libsql@0.4.5/node_modules/@libsql/ ../../node_modules/.pnpm/node_modules/@libsql/ ../../node_modules/.pnpm/node_modules/@libsql/ sync ^\.\/.*$
../../node_modules/.pnpm/libsql@0.4.5/node_modules/libsql/index.js
../../node_modules/.pnpm/@libsql+client@0.14.0_bufferutil@4.0.7_utf-8-validate@6.0.3/node_modules/@libsql/client/lib-esm/sqlite3.js
../../node_modules/.pnpm/drizzle-orm@0.35.0_@cloudflare+workers-types@4.20240512.0_@libsql+client@0.14.0_bufferutil@4._nzyd4orv5kma6pu4j3txyc6j4y/node_modules/drizzle-orm/libsql/driver.js
../../node_modules/.pnpm/drizzle-orm@0.35.0_@cloudflare+workers-types@4.20240512.0_@libsql+client@0.14.0_bufferutil@4._nzyd4orv5kma6pu4j3txyc6j4y/node_modules/drizzle-orm/libsql/index.js
../../packages/db/src/db.ts
./src/app/status-page/[domain]/_components/actions.ts

> Build failed because of webpack errors
AndriiSherman commented 1 month ago

please check drizzle-orm@0.35.2

Jumaron commented 1 month ago

please check drizzle-orm@0.35.2

Works, thank you very much for the fast fix!!!