DT
Join ServerDrizzle Team
help
maximum call stack exceeded
Weird bug where whenever I add a
where
eq
clause getting maximum call stack exceededdebugging more right now
angeError: Maximum call stack size exceeded
at <anonymous> (/home/thdxr/dev/projects/goodvisit/saguaro/node_modules/.pnpm/drizzle-orm@0.23.5_psajsodr3yuurl4pn54idjatoy/node_modules/drizzle-orm/sql/index.js:62:17)
at <anonymous> (/home/thdxr/dev/projects/goodvisit/saguaro/node_modules/.pnpm/drizzle-orm@0.23.5_psajsodr3yuurl4pn54idjatoy/node_modules/drizzle-orm/sql/index.js:62:17)
return { sql: chunk.value.join(''), params: [] };

Is it MySQL?
no postgres
I must be doing something wrong
if you could send example of query to reproduce it
we can check it
Hey, I'm facing a similar issue - any update on this ? Thanks !
Message Not Public
Sign In & Join Server To View
yes, I think this is related to having multiple instances of drizzle installed
@thdxr @jeanhdev @michmich this should be resolved by installing
in the meantime, we already have an issue to improve this - https://github.com/drizzle-team/drizzle-orm/issues/283
@thdxr @jeanhdev @michmich this should be resolved by installing
drizzle-orm
to the workspace root using -w
in the meantime, we already have an issue to improve this - https://github.com/drizzle-team/drizzle-orm/issues/283
Yes, I fixed it by installing globally on the turborepo w/ the
-w
flag ! @bloberenober helped me 💯Message Not Public
Sign In & Join Server To View
yes, you need to have a single version for all the projects
so you need to remove them anywhere except the root
This problem is still present when I dump the drizzle package to a custom db package and build that.
Then it doesn't make difference if i'm going to install it globally or not.
Are there any plans to fix this issue in the near future:
https://github.com/drizzle-team/drizzle-orm/issues/283
Then it doesn't make difference if i'm going to install it globally or not.
Are there any plans to fix this issue in the near future:
https://github.com/drizzle-team/drizzle-orm/issues/283
It's not a top priority right now, but might be one of the next tasks
so it may be done within a month
I see. Good 2 know. Thank you 🙂
Hi, there's any other workaround? Even without turborepo/monorepo couldn't fix it.
drizzle-orm: > 0.25 gives me this error
drizzle-orm: 0.24 works fine
The stacktrace took me to this file: https://github.com/drizzle-team/drizzle-orm/blob/aadde621556ce61722be2f2b23c8ec66c3408c49/drizzle-orm/src/sql/index.ts#L129
drizzle-orm: > 0.25 gives me this error
drizzle-orm: 0.24 works fine
The stacktrace took me to this file: https://github.com/drizzle-team/drizzle-orm/blob/aadde621556ce61722be2f2b23c8ec66c3408c49/drizzle-orm/src/sql/index.ts#L129
@doiská Could be the same issue. Do you use drizzle directly in your frameworks ?
Yes, but i tried both installing in workspace root and package root, same result. Even moving packages to "single projects"
Weirdly if i use at index with iife, all queries seems to work again
You should avoid to build the package by your own with tsup or tsc
Oh, mb, i was talking about my projects. Im not rebuilding drizzle
I rebuilt without turbo repo/any workspace
Oh i see. I thought cause you mentioned the monorepo. Could you show an example how your structure looks like ?
Do you mean folder structure?
Exactly
The server is where drizzle is being used
The build is made using esbuild with context api, some settings are: node16, bundle, alias '@' and loader ts
rn, drizzle is installed as server (package) dependency
Mhm and used nowhere else than inside the server ?
Is the server custom made or built with any framework like nestjs ?
Is the server custom made or built with any framework like nestjs ?
Custom made, right now just using express and some event emitters, no big deal
Theres one more thing, for every endpoint call, i use a setImmediate with promise resolving the response. Just to be similar to the way FiveM works
And no, its not being used anywhere outside server.
I tried removing it, no difference
The only way i made > 0.25 works was inside a iife, idk why
If i use drizzle directly:
It gives me the error, but using an import, it works:
@NetPromise(TwitterEvents.TweetList)
async test() {
const response = await db
.select()
.from(twitterUsers)
.innerJoin(twitterActions, eq(twitterActions.id, twitterUsers.id));
console.log(response);
// return {
// status: 'ok',
// data: []
// }
}
It gives me the error, but using an import, it works:
import { getTweets } from "@server/apps/twitter/twitter-tweets.db";
@NetPromise(TwitterEvents.TweetList)
async test() {
const response = await getTweets();
console.log(response);
// return {
// status: 'ok',
// data: []
// }
}
@doiská If you use it directly it get built twice i guess. And thats the same issue then like with monorepos mentioned above. Seems we need to wait for that fix.
im using a normal monorepo without any tools like turborepo.
Basically i have a config folder which has the schema file for drizzle + deps
Then i have 2 apps, each will run on their own docker container, the config folder will be copied to both of the containers.
What would be the workaround here?
The monorepo consists of more apps written in different langauges and i do not want to install npm packages at the root level
Basically i have a config folder which has the schema file for drizzle + deps
Then i have 2 apps, each will run on their own docker container, the config folder will be copied to both of the containers.
What would be the workaround here?
The monorepo consists of more apps written in different langauges and i do not want to install npm packages at the root level
Im doing something like this for now which works, but i hope this issue gets a proper solution soon
RUN rm -rf ./foo/node_modules/drizzle-orm
RUN rm -rf ./bar/node_modules/drizzle-orm
RUN pnpm add --global drizzle-orm pg
RUN pnpm --dir ./foo link --global drizzle-orm pg
RUN pnpm --dir ./bar link --global drizzle-orm pg
I think I get it, my problem only happens when I bundle the drizzle-orm using esbuild. If i set it as externals, it works perfectly
My esbuild config
entryPoints: [
'./src/server/index.ts'
],
outfile: './dist/server/server.js',
bundle: true,
sourcemap: true,
loader: {
'.ts': 'ts',
},
platform: 'node',
target: 'node16',
format: 'cjs',
external: ['drizzle-orm'],
define: {
'process.env.NODE_ENV': `"${process.env.NODE_ENV || 'development'}"`
},
plugins: [
esbuildDecorators({
tsconfig: './src/server/tsconfig.json'
})
],
tsconfig: './src/server/tsconfig.json',
Thanks @Siris @s1njar ^^
those of you with the problem, what version of pnpm do you have?
I have the same issue now with latest version of pnpm without turborepo
I'm also facing this issue,
pnpm 7.27.1
turbo: 1.10.0
drizzle-orm: 0.26.3
@planetscale/database: 1.7.0