I tried to follow the tutorial from Adding a Database to GraphQL, this is the code of my script.ts:
const { PrismaClient } = require("@prisma/client")
const prisma = new PrismaClient()
async function main() {
const allLinks = await prisma.link.findMany()
console.log(allLinks)
}
main()
.catch(e => {
throw e
})
.finally(async () => {
await prisma.disconnect()
})
Everytime when I run it using node src/script.ts or ts-node src/script.ts.
The requirements:
Show all links from the database using prisma client.
I tried to run the script.ts using node src/script.ts and ts-node src/script.ts but show the following error:
/usr/bin/node[20367]: ../src/node_http_parser_impl.h:529:static void node::{anonymous}::Parser::Initialize(const v8::FunctionCallbackInfo<v8::Value>&): Assertion `args[3]->IsInt32()' failed.
1: 0xa17c40 node::Abort() [/usr/bin/node]
2: 0xa17cbe [/usr/bin/node]
3: 0xa3214a [/usr/bin/node]
4: 0xc019e9 [/usr/bin/node]
5: 0xc037d7 v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) [/usr/bin/node]
6: 0x1409319 [/usr/bin/node]
This is my package.json file:
{
"name": "learn",
"version": "1.0.0",
"description": "A GraphQL Server from scratch for learning purpose.",
"main": "index.ts",
"scripts": {
"start": "dotenv -- nodemon -e ts,graphql -x ts-node src/index.ts",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"dependencies": {
"graphql-yoga": "^1.18.3"
},
"devDependencies": {
"@prisma/cli": "^2.8.1",
"@prisma/client": "^2.8.1",
"@types/node": "^14.11.2",
"dotenv-cli": "^4.0.0",
"nodemon": "^2.0.4",
"ts-node": "^9.0.0",
"typescript": "^4.0.3"
}
}
I'm with the same issue.
cc @nodejs/http @nodejs/llnode
@devsnek unavailable...
Maybe a dup of #35572?
I think the root cause is following backport PR: https://github.com/nodejs/node/pull/34131 which changes the API of the HTTPParser. The API is internal but it looks like it's used by some modules and they pass more then the expected number of arguments which is no longer ignored.
See also https://github.com/prisma/prisma-client-js/issues/907 and https://github.com/nodejs/undici/issues/448
https://github.com/nodejs/undici/blob/master/lib/node/http-parser.js#L3-L4 — caused by using the internal API directly.
Usage of that API should be fixed in [email protected]: https://github.com/nodejs/undici/issues/448#issuecomment-706070229
Could you confirm that resolving undici to 2.0.7 helps?
For now I'm downgrading my node version to v12.18.4 until the bug is fixed. It's work properly when you use node v12.18.4.
Thank you all about the replies, hopefully it will be fixed soon.
From the available information, it doesn't look like a bug in Node.js.
Let's close this as a duplicate of #35572, as it's unlikely that any new information will be present here.
I'll reopen if there will be any new info hinting that's not the case.
It was confirmed in #35572 that using a fixed version of undici helps.
Most helpful comment
I think the root cause is following backport PR: https://github.com/nodejs/node/pull/34131 which changes the API of the
HTTPParser. The API is internal but it looks like it's used by some modules and they pass more then the expected number of arguments which is no longer ignored.See also https://github.com/prisma/prisma-client-js/issues/907 and https://github.com/nodejs/undici/issues/448