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

Support prisma #2083

Closed
2 tasks done
ThatOneBro opened this issue Feb 15, 2023 · 8 comments
Closed
2 tasks done

Support prisma #2083

ThatOneBro opened this issue Feb 15, 2023 · 8 comments
Labels
ecosystem Something that relates to package or framework compatibility tracking An umbrella issue for tracking big features

Comments

@ThatOneBro
Copy link
Contributor

With the addition of an interesting async_hooks workaround by @Jarred-Sumner, we only lack a few things to get Prisma support off the ground:

After those issues are resolved, we should have prisma working in Bun

@ThatOneBro ThatOneBro added tracking An umbrella issue for tracking big features node.js Compatibility with Node.js APIs ecosystem Something that relates to package or framework compatibility and removed node.js Compatibility with Node.js APIs labels Feb 15, 2023
@ElYaiko
Copy link

ElYaiko commented Apr 29, 2023

Any updates?

@kenneropia
Copy link

👀🥹

@Zhincore
Copy link

Zhincore commented May 6, 2023

I think we/contributors should focus on the mentioned issues before there can be "any updates" in this thread...
I believe you can make this process faster by contributing to the mentioned issues.

@paperdave
Copy link
Collaborator

i should note that if you use the prisma data proxy, it works. so that's a workaround for now. the napi-based prisma engine does not work yet.

@Jarred-Sumner
Copy link
Collaborator

Here's the current debug logs where it gets before crashing:

> bun-debug index.ts
[SYS] close(20)
[0.04ms] ".env"
[SYS] close(32)
[SYS] close(36)
[SYS] openat(-2, /Users/jarred/Build/prisa/.env) = 52
[SYS] fstat(52) = 0
[SYS] read(52, 479) = 463 (0.015ms)
[SYS] read(52, 16) = 0 (0.001ms)
[SYS] close(52)
[SYS] openat(-2, /Users/jarred/Build/prisa/.env) = 52
[SYS] fstat(52) = 0
[SYS] read(52, 479) = 463 (0.005ms)
[SYS] read(52, 16) = 0 (0.001ms)
[SYS] close(52)
[SYS] openat(-2, /Users/jarred/Build/prisa/node_modules/.prisma/client/schema.prisma) = 52
[SYS] fstat(52) = 0
[SYS] read(52, 590) = 574 (0.003ms)
[SYS] read(52, 16) = 0 (0.001ms)
[SYS] close(52)
[bun]: async_hooks has not been implemented yet :(
[napi] napi_create_string_utf8: CustomGC
[napi] napi_create_threadsafe_function
[napi] napi_unref_threadsafe_function
[napi] napi_create_string_utf8: prisma log callback
[napi] napi_create_threadsafe_function
[napi] napi_unref_threadsafe_function
[napi] napi_is_array
[napi] napi_is_buffer
[napi] napi_get_array_length
[napi] napi_get_element
[napi] napi_get_value_string_utf8: datamodel
[napi] napi_get_element
[napi] napi_get_value_string_utf8: // This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "sqlite"
  url      = env("DATABASE_URL")
}

model User {
  id    Int     @id @default(autoincrement())
  email String  @unique
  name  String?
  posts Post[]
}

model Post {
  id        Int     @id @default(autoincrement())
  title     String
  content   String?
  published Boolean @default(false)
  author    User    @relation(fields: [authorId], references: [id])
  authorId  Int
}

[napi] napi_get_element
[napi] napi_get_value_string_utf8: env
[napi] napi_get_element
[napi] napi_is_array
[napi] napi_is_buffer
[napi] napi_get_array_length
[napi] napi_get_element
// -- [ENVIRONMENT VARIABLES SKIPPED] --
[napi] napi_get_value_string_utf8: file:./dev.db
[napi] napi_get_element
[napi] napi_get_value_string_utf8: logQueries
[napi] napi_get_element
[napi] napi_get_value_bool
[napi] napi_get_element
[napi] napi_get_value_string_utf8: ignoreEnvVarErrors
[napi] napi_get_element
[napi] napi_get_value_bool
[napi] napi_get_element
[napi] napi_get_value_string_utf8: datasourceOverrides
[napi] napi_get_element
[napi] napi_is_array
[napi] napi_is_buffer
[napi] napi_get_array_length
[napi] napi_get_element
[napi] napi_get_value_string_utf8: logLevel
[napi] napi_get_element
[napi] napi_get_value_string_utf8: error
[napi] napi_get_element
[napi] napi_get_value_string_utf8: configDir
[napi] napi_get_element
[napi] napi_get_value_string_utf8: /Users/jarred/Build/prisa/prisma
[napi] napi_create_object
[napi] napi_create_string_utf8: aead147aa326ccb985dcfed5b065b4fdabd44b19
[napi] napi_create_string_utf8: 0.1.0
[napi] napi_is_array
[napi] napi_is_buffer
[napi] napi_get_array_length
[napi] napi_get_element
[napi] napi_get_value_string_utf8: datamodel
[napi] napi_get_element
[napi] napi_get_value_string_utf8: // This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "sqlite"
  url      = env("DATABASE_URL")
}

model User {
  id    Int     @id @default(autoincrement())
  email String  @unique
  name  String?
  posts Post[]
}

model Post {
  id        Int     @id @default(autoincrement())
  title     String
  content   String?
  published Boolean @default(false)
  author    User    @relation(fields: [authorId], references: [id])
  authorId  Int
}

[napi] napi_get_element
[napi] napi_get_value_string_utf8: datasourceOverrides
[napi] napi_get_element
[napi] napi_is_array
[napi] napi_is_buffer
[napi] napi_get_array_length
[napi] napi_get_element
[napi] napi_get_value_string_utf8: ignoreEnvVarErrors
[napi] napi_get_element
[napi] napi_get_value_bool
[napi] napi_get_element
[napi] napi_get_value_string_utf8: env
[napi] napi_get_element
[napi] napi_is_array
[napi] napi_is_buffer
[napi] napi_get_array_length
[napi] napi_get_element
// -- [ENVIRONMENT VARIABLES SKIPPED] --
[napi] napi_get_value_string_utf8: file:./dev.db
[napi] napi_create_string_utf8:
[napi] napi_create_object
[napi] napi_create_string_utf8: generators
[napi] napi_create_array_with_length
[napi] napi_create_string_utf8:
[napi] napi_create_object
[napi] napi_create_string_utf8: name
[napi] napi_create_string_utf8: client
[napi] napi_create_string_utf8: provider
[napi] napi_create_string_utf8:
[napi] napi_create_object
[napi] napi_create_string_utf8: fromEnvVar
[napi] napi_get_null
[napi] napi_create_string_utf8: value
[napi] napi_create_string_utf8: prisma-client-js
[napi] napi_create_string_utf8: output
[napi] napi_get_null
[napi] napi_create_string_utf8: config
[napi] napi_create_string_utf8:
[napi] napi_create_object
[napi] napi_create_string_utf8: binaryTargets
[napi] napi_create_array_with_length
[napi] napi_create_string_utf8: previewFeatures
[napi] napi_create_array_with_length
[napi] napi_set_element
[napi] napi_create_string_utf8: datasources
[napi] napi_create_array_with_length
[napi] napi_create_string_utf8:
[napi] napi_create_object
[napi] napi_create_string_utf8: name
[napi] napi_create_string_utf8: db
[napi] napi_create_string_utf8: provider
[napi] napi_create_string_utf8: sqlite
[napi] napi_create_string_utf8: activeProvider
[napi] napi_create_string_utf8: sqlite
[napi] napi_create_string_utf8: url
[napi] napi_create_string_utf8:
[napi] napi_create_object
[napi] napi_create_string_utf8: fromEnvVar
[napi] napi_create_string_utf8: DATABASE_URL
[napi] napi_create_string_utf8: value
[napi] napi_get_null
[napi] napi_create_string_utf8: schemas
[napi] napi_create_array_with_length
[napi] napi_set_element
[napi] napi_create_string_utf8: warnings
[napi] napi_create_array_with_length
[napi] napi_get_value_string_utf8: {"traceparent":"00-10-10-00"}
[napi] napi_create_promise
[napi] napi_create_string_utf8: napi_resolve_deferred
[napi] napi_create_threadsafe_function
fish: Job 1, 'bun-debug index.ts' terminated by signal SIGSEGV (Address boundary error)

The bug is probably in napi_create_threadsafe_function. It might also be in napi_create_promise. But more likely napi_create_threadsafe_function

@Jarred-Sumner
Copy link
Collaborator

One bug in threadsafe function has been fixed by @cirospaciari in #3162

#3164 fixes the issue with import.meta being inserted into CommonJS modules (which are not ESM anymore in Bun)

now we have a null pointer dereference in the tokio / napi code. Guessing an argument is not set.

image

@Jarred-Sumner
Copy link
Collaborator

guess what

@Jarred-Sumner
Copy link
Collaborator

Jarred-Sumner commented Jun 3, 2023

Fixed by @cirospaciari in #3176

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ecosystem Something that relates to package or framework compatibility tracking An umbrella issue for tracking big features
Projects
None yet
Development

No branches or pull requests

6 participants