question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Preview feature feedback: Node-API support (`nApi`)

See original GitHub issue

Please share your feedback about the nApi functionality released in v2.20.0 in this issue.

  • If you encounter a bug, please open a bug report in this repo.
  • If the feature is working well for you, please share this in a comment below or leave a 👍 on this issue.

If you have any questions, don’t hesitate to ask them in the #prisma-client channel in the Prisma Slack.

Known Limitations

  • (Resolved) You can’t have more than one instance of the Prisma Client yet, so this will not work properly:
    const prisma1 = new PrismaClient()
    const prisma2 = new PrismaClient()
    
  • (Resolved) Currently, logging queries does not work with Node-API and Jest (Issue). For example, the following will not output any query logs. (Note: This seems to only be the case when using jest)
    const prisma = new PrismaClient({
      log: ['query']
    })
    
  • (Resolved) Node-API libraries do not work with process mocking of Jest (issue)
  • Node-API does not work on M1 ARM Macs, Apple Silicon (issue)
  • Node-API does not work on 32bit Node (issue)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:6
  • Comments:51 (32 by maintainers)

github_iconTop GitHub Comments

14reactions
k-saecommented, Jun 24, 2021

Originally posted here: #5792.

I had a major performance drawback when I was migrating from sequelize and seems the nApi solved it for me. Here are the details:

Environment

os: Linux (5.10.42-1-MANJARO)
DB: MySQL (10.4.19-MariaDB)
Node: v16.3.0
prisma: 2.25

Prisma schema:

model employees {
  emp_no       Int              @id
  birth_date   DateTime         @db.Date
  first_name   String           @db.VarChar(14)
  last_name    String           @db.VarChar(16)
  gender       employees_gender
  hire_date    DateTime         @db.Date
}

DB: employees_db

Code:

for (let index = 0; index < 2000; index++) {
    const employees = await prisma.employees.findMany({
      take: 100
    })
}

Results:

prisma: 42.497s
nApiPrisma: 6.146s

Full code here: https://github.com/k-sae/employees_prisma

7reactions
pimeyscommented, Jun 3, 2021

Throughput solved in latest dev.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How We Migrated Realm JavaScript From NAN to N-API
The Realm JavaScript team has reimplemented the Realm JS Node.js SDK from the ground up to use N-API. Here we describe how and...
Read more >
Node-API | Node.js v19.3.0 Documentation
Node -API (formerly N-API) is an API for building native Addons. It is independent from the underlying JavaScript runtime (for example, V8) and...
Read more >
What's new in Prisma? (Q3/2021)
In 2.20.0 we introduced a Preview feature, the Node-API library, as a more efficient way to communicate with the Prisma Engine binary.
Read more >
Next Generation N-API - SlideShare
The world of Node native add-on development continues to rapidly evolve. After widespread adoption of N-API starting last year, the Node ...
Read more >
Node.js Archives - Page 3 of 6 - OpenJS Foundation
js project. N-API has always stood for Node-API but was often pronounced NAPI. A concern was raised, that when pronounced that way, it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found