Skip to main content

Get the Reddit app

Scan this QR code to download the app now
Or check it out in the app stores

r/node

members
online

Do not use Prisma for production heavy applications Do not use Prisma for production heavy applications

Prisma is the worst for production heavy (I will go as far as to say for any) applications. I had really high hopes for it, and pitched to use Prisma ORM for our new microservice, however, 6 months in, it became disgustingly hard to maintain and justify resource consumption. I can provide several examples where we had a trouble with it.

For the context, we are running k8s node+express backend server, our queries are simple (no relative queries or anything, just retrieving record - updating record - writing record). We had 4 pods on average with 400mb RAM (scaled to 1000mb due to Prisma) - and Prisma was crashing with P1001 or P1024 errors, randomly, out of nowhere. We spent days if not weeks trying to figure out what's going on (yes, we also looked at their "suggestions" - these are jokes like optimize your query, manually limit connections etc etc), the best quick patch was to scale AWS RDS, but upon further investigation we found the following:

  • Prisma has issues with killing connections on pod death

    • trying to fix it with manual killing didn't help, we literally at some point had 100 connections dangling somehow (4 pods 9 connection limit = 36 connections, not 100 :/ )

  • Prisma has high error rate even in simple queries!!! We didn't get flagged on these, since we were assuming it within acceptable error range for us, but it's something you should be aware of. This article claims it was within 2% rate. In our manual tests (local pg - 20ms delay between requests - 1200 total) - we managed to get 20-30% rate that is not recovering, which is a joke to be honest, how the hell VCs are even funding that?

Our main assumption that the issue has to do with their internal engine, I think it lacks decent optimization at this point in time. In the end we switched to another provider (Drizzle) with node-pg as the engine, which seems to be the best and more stable solution in the market. So far we are extremely happy, since we can type cast on schema, which was lacking in Prisma, and both performance and stability allow us to not even think about it.

If you still considering using Prisma, please, use the Hexagonal Architecture and split your DB from the service by at least one layer. That will allow you to switch to another db in days, without having a headache of updating every single consumer :)


Searching for more leverage and flexibility in your portfolio? Explore options trading with TradeStation. Learn about one of the most versatile financial instruments available - options trading – and trade on TradeStation's powerful platform.
Searching for more leverage and flexibility in your portfolio? Explore options trading with TradeStation. Learn about one of the most versatile financial instruments available - options trading – and trade on TradeStation's powerful platform.


Handling Long Excel Generation Times in Node.js Backend with AWS Lambda Timeout Constraint Handling Long Excel Generation Times in Node.js Backend with AWS Lambda Timeout Constraint

I need to fetch data from MongoDB, convert it into an Excel format, generate an Excel file in Node.js, upload the file to AWS S3, and then send a response to the user saying the Excel file is generated and uploaded.

However, AWS Lambda has a timeout of 30 seconds, which is an issue since the Excel generation time depends on the size of the data. The data is huge, about 50k rows, and it takes a lot of time.

I have to generate the Excel file on the backend using Node.js and Express. It can't be done on the client side.

How can I solve this issue? Additionally, how do I ensure that the API does not block other users while the Excel generation is running for one user, causing others to wait because the API is blocked?

please Any suggestions?


npm or yarn not able to create directories on windows setup? npm or yarn not able to create directories on windows setup?

While trying to use - npm init or npm install or yarn install, it seems to always got stuck on where it needs to create files on Windows 11 I have already tried:

  1. Clearing all sorts of caches

  2. Reinstalling various version of node using all possible methods on Windows

  3. Checked PATH settings

  4. Used powershell and cmd.exe using admin privileges.

But, I am stuck with error like below:

PS C:\Users\xyz\Documents\GitHub\wwjs> yarn init
! Corepack is about to download https://repo.yarnpkg.com/4.2.2/packages/yarnpkg-cli/bin/yarn.js? Do you want to continue? [Y/n] Y
Internal Error: ENOENT: no such file or directory, open 'C:\Users\xyz\Documents\GitHub\wwjs\package.json'Error: ENOENT: no such file or directory, open 'C:\Users\xyz\Documents\GitHub\wwjs\package.json'

And:

0 verbose cli C:\Program Files\nodejs\node.exe C:\Users\xyz\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js1 info using npm@10.8.02 info using node@v22.2.03 silly config load:file:C:\Users\xyz\AppData\Roaming\npm\node_modules\npm\npmrc4 silly config load:file:C:\Users\xyz\Documents\GitHub\wwjs\.npmrc5 silly config load:file:C:\Users\xyz\.npmrc6 silly config load:file:C:\Users\xyz\AppData\Roaming\npm\etc\npmrc7 verbose title npm init8 verbose argv "init" "--yes"9 verbose logfile logs-max:10 dir:C:\Users\xyz\AppData\Local\npm-cache\_logs\2024-05-28T12_52_48_262Z-10 verbose logfile C:\Users\xyz\AppData\Local\npm-cache\_logs\2024-05-28T12_52_48_262Z-debug-0.log11 silly logfile start cleaning logs, removing 1 files12 silly logfile done cleaning log files13 verbose stack Error: ENOENT: no such file or directory, open 'C:\Users\xyz\Documents\GitHub\wwjs\package.json'13 verbose stack     at async open (node:internal/fs/promises:641:25)13 verbose stack     at async writeFile (node:internal/fs/promises:1224:14)13 verbose stack     at async PackageJson.save (C:\Users\xyz\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\package-json\lib\index.js:255:14)13 verbose stack     at async init (C:\Users\xyz\AppData\Roaming\npm\node_modules\npm\node_modules\init-package-json\lib\init-package-json.js:125:5)13 verbose stack     at async Init.template (C:\Users\xyz\AppData\Roaming\npm\node_modules\npm\lib\commands\init.js:168:20)13 verbose stack     at async Init.exec (C:\Users\xyz\AppData\Roaming\npm\node_modules\npm\lib\commands\init.js:48:5)13 verbose stack     at async Npm.exec (C:\Users\xyz\AppData\Roaming\npm\node_modules\npm\lib\npm.js:207:9)13 verbose stack     at async module.exports (C:\Users\xyz\AppData\Roaming\npm\node_modules\npm\lib\cli\entry.js:74:5)14 error code ENOENT15 error syscall open16 error path C:\Users\xyz\Documents\GitHub\wwjs\package.json17 error errno -405818 error enoent ENOENT: no such file or directory, open 'C:\Users\xyz\Documents\GitHub\wwjs\package.json'19 error enoent This is related to npm not being able to find a file.19 error enoent20 verbose cwd C:\Users\xyz\Documents\GitHub\wwjs21 verbose os Windows_NT 10.0.2200022 verbose node v22.2.023 verbose npm  v10.8.024 verbose exit -405825 verbose code -405826 error A complete log of this run can be found in: C:\Users\xyz\AppData\Local\npm-cache\_logs\2024-05-28T12_52_48_262Z-debug-0.log