prisma: After upgrading to Prisma 3.10 from 3.9, remix site crashes on connection (Codesigning issue on M1 Macs)
Bug description
In a Remix.run site I’m developing, I updated Prisma from 3.9.1 to 3.10. This made the server crash with the following message.
Downgrading to Prisma 3.9.2 worked again. Tested multiple times to switch version with consistent behaviour.
Watching Remix app in development mode...
💿 Built in 228ms
Remix App Server started at http://localhost:3000
fatal error: all goroutines are asleep - deadlock!
[1] 26432 killed npx remix dev --debug
goroutine 1 [semacquire]:
sync.runtime_Semacquire(0x1400001ad28)
runtime/sema.go:56 +0x38
sync.(*WaitGroup).Wait(0x1400001ad20)
sync/waitgroup.go:130 +0xa4
main.runService(0x1)
github.com/evanw/esbuild/cmd/esbuild/service.go:138 +0x494
main.main()
github.com/evanw/esbuild/cmd/esbuild/main.go:203 +0x1f0
goroutine 6 [chan receive]:
main.runService.func1(0x140000261e0, 0x1400001ad20)
github.com/evanw/esbuild/cmd/esbuild/service.go:66 +0x3c
created by main.runService
github.com/evanw/esbuild/cmd/esbuild/service.go:64 +0x1a8
goroutine 7 [chan receive]:
main.(*serviceType).sendRequest(0x140000261e0, {0x1029e7320, 0x14003885ce0})
github.com/evanw/esbuild/cmd/esbuild/service.go:163 +0x104
main.runService.func2(0x140000261e0)
github.com/evanw/esbuild/cmd/esbuild/service.go:92 +0x40
created by main.runService
github.com/evanw/esbuild/cmd/esbuild/service.go:89 +0x2b8
Note that Prisma studio works in both versions.
How to reproduce
Unclear. Similar issues have been discussed in the Remix discord (https://discord.com/channels/770287896669978684/938793097414975528/938795339757010964)
See also https://github.com/prisma/prisma/issues/11995
Expected behavior
No response
Prisma information
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
System seems to crash on connection to the database.
Environment & setup
Computer: MacBook Pro 14 inch, M1 Max, macOS Monterey 12.2 Database: Postgresql 14.1 installed from homebrew Node: v17.6.0 Remix: 1.2.2 (also tested 1.2.1)
Prisma Version
Non-working version
Environment variables loaded from .env
prisma : 3.10.0
@prisma/client : 3.10.0
Current platform : darwin-arm64
Query Engine (Node-API) : libquery-engine 73e60b76d394f8d37d8ebd1f8918c79029f0db86 (at node_modules/@prisma/engines/libquery_engine-darwin-arm64.dylib.node)
Migration Engine : migration-engine-cli 73e60b76d394f8d37d8ebd1f8918c79029f0db86 (at node_modules/@prisma/engines/migration-engine-darwin-arm64)
Introspection Engine : introspection-core 73e60b76d394f8d37d8ebd1f8918c79029f0db86 (at node_modules/@prisma/engines/introspection-engine-darwin-arm64)
Format Binary : prisma-fmt 73e60b76d394f8d37d8ebd1f8918c79029f0db86 (at node_modules/@prisma/engines/prisma-fmt-darwin-arm64)
Default Engines Hash : 73e60b76d394f8d37d8ebd1f8918c79029f0db86
Studio : 0.458.0
Working version
Environment variables loaded from .env
prisma : 3.9.2
@prisma/client : 3.9.2
Current platform : darwin-arm64
Query Engine (Node-API) : libquery-engine bcc2ff906db47790ee902e7bbc76d7ffb1893009 (at node_modules/@prisma/engines/libquery_engine-darwin-arm64.dylib.node)
Migration Engine : migration-engine-cli bcc2ff906db47790ee902e7bbc76d7ffb1893009 (at node_modules/@prisma/engines/migration-engine-darwin-arm64)
Introspection Engine : introspection-core bcc2ff906db47790ee902e7bbc76d7ffb1893009 (at node_modules/@prisma/engines/introspection-engine-darwin-arm64)
Format Binary : prisma-fmt bcc2ff906db47790ee902e7bbc76d7ffb1893009 (at node_modules/@prisma/engines/prisma-fmt-darwin-arm64)
Default Engines Hash : bcc2ff906db47790ee902e7bbc76d7ffb1893009
Studio : 0.457.0
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 3
- Comments: 19 (8 by maintainers)
I experienced something similar though with a Next.js application - I wasn’t able to put together a reproduction as my clean repo didn’t crash the process, so I decided to try deleting all
.prismagenerated directories before runningprisma generateagain, and that worked!I have a monorepo, so I located all
.prismadirectories withfind . -name .prisma, then deleted each one.So at least for me, the issue manifested when I already had a generated client from 3.9, and cleaning up the old version before running generate again appears to have fixed it.
@pantharshit00 do you have an M1 Mac? From my understanding this specifically triggers on
darwin-arm64.The steps to reproduce that work for me, if useful:
package.jsonwith the following:yarn install && yarn prisma generatepackage.jsonto the following:yarn install && yarn prisma generateMight be superfluous since the cause seems to have been found by @jacobwgillespie above, but can confirm the issue also happens with SvelteKit (so not only Remix) after updating Prisma to
3.10.Attempting to connect after starting a dev server ends the process with
SIGKILL.I am also on M1 and I did run
prisma generateafter update. Removing./node-modules/.prismaand rerunningprisma generatesolved the issue.I still have a copy of my test files, here’s some zips:
3.9.xfirst, then3.10.x: https://drive.google.com/file/d/1lAQbSArGgQAiGdHD5QXRqo9aGZCSoalX/view?usp=sharing3.10.x: https://drive.google.com/file/d/1WOoxtjxdQrYcNjLKRsj6VtwjmX7LjJiG/view?usp=sharingYou can see the leftover
esmdirectory in the first zip…One of the things that lead to the finding above was that if I made a copy of the project the copy worked. As in, if I upgraded from 3.9 to 3.10, the project was broken, but if I
cp -r node_modulesto another directory it worked. That seemed to imply that it wasn’t actually the contents of the files, but something about their metadata instead, which lead to investigating the kernel error messages.@janpio fascinating, this is an interesting one, I was able to reproduce! For extra context, I did run
prisma generateafter upgrading to 3.10, which did not fix the issue until I deleted the.prisma/clientdirectory.So the issue is macOS code signing on M1 Macs!
Specifically, code signing breaks when replacing a binary with the contents of a new binary, for example you can reproduce this via the following:
By creating the
examplebinary as a copy of the first binary, the binary is considered safe, but when replacing it with the copy of a different binary, it’s considered unsafe.I believe that’s what is happening here, when upgrading from 3.9 to 3.10, the file
node_modules/.prisma/client/libquery_engine-darwin-arm64.dylib.nodeis replaced with the 3.10 version, but since its path / inode is the same as before, it is considered no longer code signed by the macOS sandbox.This manifests as the following log lines in Console:
Note the
cs_mtime:1645742717.771967254 != mtime:1645742737.976117428on the rejection, the file mtime at initial creation (v3.9) no longer matches the current mtime after upgrade (v3.10)I think the potential fixes would be:
.dylib.nodefile inprisma generatebefore generating the new client (or delete the whole.prisma/clientfor that matter)libquery_...3.10.0.dylib.node, etc)Another benefit to (1) is it would clean up old files, I also discovered that after upgrading from 3.9 to 3.10 a leftover
.prisma/client/runtime/esmdirectory was still present from 3.9, but that turned out to be a red herring. But if Prisma cleaned its client directory before generate, that would potentially also clean up leftovers likeesm.Credit to https://openradar.appspot.com/FB8914243 for the simple reproduction of the issue above.
Got the same issue when upgrading Prisma from version 3.14 to 3.15. I’m on a MacBook Pro (14-inch, 2021) with an M1 Pro chip.
Remix builds the site, and starts an express server. The Prisma connection is managed through this code
which is form the Remix documentation (https://remix.run/docs/en/v1/tutorials/jokes#connect-to-the-database). As far as I can tell, it deadlocks when trying to connect to the database.
I have unfortunately not had the time to attempt a reproducing example, but I hope to do so. I wanted to create a bug before I had a reproduction with enough description that others could find it if they encounter the same issue.