Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prisma CLI is throwing segmentation fault with node 14 (fs.writeFileSync arg) #2361

Closed
pantharshit00 opened this issue May 4, 2020 · 10 comments
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. tech/typescript Issue for tech TypeScript.
Milestone

Comments

@pantharshit00
Copy link
Contributor

pantharshit00 commented May 4, 2020

Bug description

Prisma CLI is throwing Segmentation fault when I try running it with node 14.
image

I further investigated this and looks like our download script is failing:

╰─ npm install -g @prisma/cli                                                                                             ─╯

> @prisma/cli@2.0.0-beta.4 preinstall /Users/harshit/.nvm/versions/node/v14.1.0/lib/node_modules/@prisma/cli
> node preinstall/index.js

  preinstall { installedGlobally: null } +0ms
/Users/harshit/.nvm/versions/node/v14.1.0/bin/prisma -> /Users/harshit/.nvm/versions/node/v14.1.0/lib/node_modules/@prisma/cli/build/index.js
/Users/harshit/.nvm/versions/node/v14.1.0/bin/prisma2 -> /Users/harshit/.nvm/versions/node/v14.1.0/lib/node_modules/@prisma/cli/build/index.js

> @prisma/cli@2.0.0-beta.4 install /Users/harshit/.nvm/versions/node/v14.1.0/lib/node_modules/@prisma/cli
> node download-build/index.js

  prisma:download TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received type number (1588600217460)
  prisma:download     at Object.writeFileSync (fs.js:1380:5)
  prisma:download     at createLockFile (/Users/harshit/.nvm/versions/node/v14.1.0/lib/node_modules/@prisma/cli/download-build/index.js:1:56155)
  prisma:download     at main (/Users/harshit/.nvm/versions/node/v14.1.0/lib/node_modules/@prisma/cli/download-build/index.js:1:55861)
  prisma:download     at Object.197 (/Users/harshit/.nvm/versions/node/v14.1.0/lib/node_modules/@prisma/cli/download-build/index.js:1:56314)
  prisma:download     at __webpack_require__ (/Users/harshit/.nvm/versions/node/v14.1.0/lib/node_modules/@prisma/cli/download-build/index.js:1:154)
  prisma:download     at startup (/Users/harshit/.nvm/versions/node/v14.1.0/lib/node_modules/@prisma/cli/download-build/index.js:1:291)
  prisma:download     at module.exports.3 (/Users/harshit/.nvm/versions/node/v14.1.0/lib/node_modules/@prisma/cli/download-build/index.js:1:346)
  prisma:download     at Object.<anonymous> (/Users/harshit/.nvm/versions/node/v14.1.0/lib/node_modules/@prisma/cli/download-build/index.js:1:356)
  prisma:download     at Module._compile (internal/modules/cjs/loader.js:1176:30)
  prisma:download     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1196:10) +0ms
+ @prisma/cli@2.0.0-beta.4
updated 1 package in 0.517s`

I narrowed down this error to

fs.writeFileSync(lockFile, Date.now())
call. The API indeed got a change in version 14:
image

So now node doesn't automatically convert number into string which Date.now() returns.

How to reproduce

Steps to reproduce the behavior:

  1. Install node 14
  2. Run npm install -g @prisma/cli to install Prisma CLI globally
  3. Run prisma -v

Expected behavior

Prisma CLI should not return segmentation fault

Environment & setup

  • OS: MacOS 10.15.4
  • Database: Postgresql
  • Prisma version:
  • Node.js version: 14.1.0
@Jolg42
Copy link
Contributor

Jolg42 commented May 4, 2020

@pantharshit00 now I get DEBUG="*" npm i -g @prisma/…' terminated by signal SIGSEGV (Address boundary error)

With env DEBUG="*" npm i -g @prisma/cli@2.0.0-alpha.1184 v14.1.0.

@Jolg42
Copy link
Contributor

Jolg42 commented May 4, 2020

It looks like the terminated by signal SIGSEGV (Address boundary error) is because Node 14 has a bug 🙈

@janpio janpio added this to the Beta 5 milestone May 4, 2020
@janpio janpio added the tech/typescript Issue for tech TypeScript. label May 4, 2020
@pantharshit00
Copy link
Contributor Author

Yes, looks like segfault is actually coming from nodejs

@Jolg42
Copy link
Contributor

Jolg42 commented May 5, 2020

So we added a workaround for this but the underlying bug in Node still exists
I tried to get a stack trace but nothing worked 🤷‍♂️

So the easiest reproduction so far is

mkdir repro-node-14
cd repro-node-14
node -v # should be v14 (for me v14.1.0)
npm init -y
npm i @prisma/sdk@2.0.0-alpha.1185
# Sometimes you have to repeat the install 🤷‍♂️ 
npm i @prisma/sdk@2.0.0-alpha.1185
npm i @prisma/sdk@2.0.0-alpha.1185

Output

> @prisma/sdk@2.0.0-alpha.1185 postinstall /Users/j42/Dev/repro/node-SIGSEGV-ddownload/node_modules/@prisma/sdk
> node scripts/download.js

version: f401775ef1c681c705db8fd8d6cecaa5a4eb44fd
fish: 'npm i @prisma/sdk@2.0.0-alpha.1…' terminated by signal SIGSEGV (Address boundary error)

@Jolg42
Copy link
Contributor

Jolg42 commented May 5, 2020

Related issue (same? SIGSEGV)
#1819

@pantharshit00
Copy link
Contributor Author

Related issue (same? SIGSEGV) #1819

No, that issue was tracking Redwood segfault issue. @AhmedElywa reported the segfault in that issue thinking it was related but it is a separate issue so I opened this one.

@janpio
Copy link
Member

janpio commented May 6, 2020

Do we have an issue that tracks the Node 14 problem on our side so we can close it when Node fixed it? Do we have a node issue to point people to?

@timsuchanek
Copy link
Contributor

nodejs/node#33263

@Jolg42 Jolg42 changed the title Prisma CLI is throwing segmentation fault with node 14 Prisma CLI is throwing segmentation fault with node 14 (fs.writeFileSync arg) May 6, 2020
@skworden
Copy link

skworden commented May 20, 2022

I ran into this problem today when trying to use db seed. It worked with node 18 versions before 18.1.0. However, it started throwing this error again today with node v18.1.0. I downgraded to LTS 16.15.0 using nvm (nvm use v16), and it works again.

@janpio
Copy link
Member

janpio commented May 23, 2022

We have tests running with Node 18.2.0 - and passing - so if you have a way to reproduce this, please open a new issue so we can investigate. Something not working is problematic and should be looked at.

jay16213 added a commit to jay16213/fire-board that referenced this issue Mar 14, 2023
  - need to use node v16.19.1 to run seed command correctly
    - reference: prisma/prisma#2361
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. tech/typescript Issue for tech TypeScript.
Projects
None yet
Development

No branches or pull requests

5 participants