Repository navigation
Closed
Labels
bug/1-unconfirmedBug should have enough information for reproduction, but confirmation has not happened yet.kind/bugA reported bug.tech/typescriptIssue for tech TypeScript.topic: performance
Milestone
Description
Bug description
i am building graphql server with context having prisma connection.
Context.
/*
* IMPORTS
*/
import Redis from 'ioredis' // Npm: redis client.
import _ from 'underscore' // Npm: utility module.
import { createPubSub } from 'graphql-yoga' // Npm: graphql subscriptions.
import { createRedisEventTarget } from '@graphql-yoga/redis-event-target' // Npm: graphql subscriptions.
import { PrismaClient } from '@prisma/client' // Npm: prisma client for database.
/*
* SIBLINGS
*/
import Debug from './Debug'
import Session from './Session'
import RoutePlan, { RoutePlans } from './RoutePlan'
import SmppManager, { SmppManagers } from './SmppManager'
import * as Utility from './Utility'
/*
* GLOBALS
*/
const _Redis = new Redis(`rediss://${CONFIG_RC.cache.username}:${CONFIG_RC.cache.password}@${CONFIG_RC.cache.host}:${CONFIG_RC.cache.port}/1`)
const _Debug = new Debug({ 'watch': ['packages/routes/', 'packages/dyna_modules/', 'packages/middleware/'], 'showLog': 'dev' === CONFIG_RC.env })
const _CreatePubsub = createPubSub({ 'eventTarget': createRedisEventTarget({ 'publishClient': _Redis, 'subscribeClient': _Redis }) })
const _PrismaClient = new PrismaClient({
log: ['info']
})
/**
* Creates a context object for the application.
* @param {Object} options - The options for creating the context.
* @param {Object} options.request - The request object.
* @param {Function} options.ExecuteGraph - The function for executing the GraphQL query.
* @returns {Promise<Object>} The context object.
*/
const Context = async ({ request = { 'headers': {} }, ExecuteGraph }) => {
// Const assignment.
const _context = {
'isContext': true,
'host': CONFIG_RC.host || (request && request.headers ? request.headers.host : void 0),
'Debug': _.extend(_Debug.Main, _.omit(_Debug, 'Main')),
'Pubsub': _CreatePubsub,
'DataBase': _PrismaClient,
'RoutePlan': RoutePlans,
'RoutePlanBuilder': (j, $options = {}) => new RoutePlan(j, { ...$options, 'context': _context }),
'SmppManager': SmppManagers,
'SmppManagerBuilder': ($options = {}) => new SmppManager({ ...$options, 'context': _context }),
'Utility': Utility,
'ExecuteGraph': ExecuteGraph
}
// Check request session.
const _Session_ = await new Session({ request }, _context)
/*
* Only return _Session_ if return is
* not instanceof Error.
*/
if (_Session_ && ('TokenExpiredError' === _Session_.name || _Session_ instanceof Error)) throw _Session_
else Object.assign(_context, { 'Session': _Session_ })
// Return context with server
return _context
}
/*
* EXPORTS
*/
export default Context
Now when ever i log context for some debugging...suddenly server slows down. after month of impatience i am writing this down that Prisma is soely responsiblie.. when i remove it from context and then log it then server works perfectly fine...now today only node.js is getting assertion error.
How to reproduce
Expected behavior
Just curious why it is that much heavy ?
Prisma information
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = "postgresql://doadmin:AVNS_7Zdgm8lfnuj50-QZHwF@main-database-do-user-14838706-0.c.db.ondigitalocean.com:25061/Backend?sslmode=require&connection_limit=47&pgbouncer=true"
}
model Account {
id String @id @unique @default(cuid())
createdAt DateTime @default(now()) @db.Timestamp(6)
updatedAt DateTime @default(now()) @updatedAt @db.Timestamp(6)
isActive Boolean @default(false)
fullName String?
password String?
isBlocked Boolean @default(false)
thumbnailStoredAt Json? @db.Json
email String? @unique(map: "email_1676392778723_index")
address String?
displayName String?
role String?
bio String?
phone String?
technicalEmail String?
referralId String? @unique(map: "referralid_1677253409214_index")
profileCoverThumbnailStoredAt Json? @db.Json
website String?
accountType ACCOUNT_TYPE
activeAs ACCOUNT_TYPE
Customer Customer[]
Rate Rate[]
RatePlan RatePlan[]
Route Route[]
RoutePlan RoutePlan[]
Smpp Smpp[]
Vendor Vendor[]
ManagerCustomer Customer[] @relation("AccountManager")
CustomerAccount CustomerAccount[]
}
model Company {
id String @id @unique @default(cuid())
createdAt DateTime @default(now()) @db.Timestamp(6)
updatedAt DateTime @default(now()) @updatedAt @db.Timestamp(6)
displayName String?
email String?
country String?
referenceNumber String?
phone Float?
Customer Customer[]
}
model Billing {
id String @id @unique @default(cuid())
createdAt DateTime @default(now()) @db.Timestamp(6)
updatedAt DateTime @default(now()) @updatedAt @db.Timestamp(6)
email String[]
smsPrice Float?
currency String?
alertAmount Float?
address String?
creditLimit Float? @default(1)
period BILLING_PERIOD
enableAutoInvoicing Boolean? @default(false)
smsType String?
Customer Customer[]
Vendor Vendor[]
}
model Entity {
id String @id @unique @default(cuid())
createdAt DateTime @default(now()) @db.Timestamp(6)
updatedAt DateTime @default(now()) @updatedAt @db.Timestamp(6)
displayName String
prefix String
logo String
email String
address String
Invoice Invoice[]
}
model Invoice {
id String @id @unique @default(cuid())
createdAt DateTime @default(now()) @db.Timestamp(6)
updatedAt DateTime @default(now()) @updatedAt @db.Timestamp(6)
amount Float?
dueDate DateTime?
taxPercent Float? @default(0)
invoiceStoredAt Json? @db.Json
isAutoGenerated Boolean? @default(false)
Customer__fk__ String?
Customer Customer? @relation(fields: [Customer__fk__], references: [id])
Sms__fk__ String?
Sms Sms? @relation(fields: [Sms__fk__], references: [id])
Entity__fk__ String?
Entity Entity? @relation(fields: [Entity__fk__], references: [id])
}
model Customer {
id String @id @unique @default(cuid())
createdAt DateTime @default(now()) @db.Timestamp(6)
updatedAt DateTime @default(now()) @updatedAt @db.Timestamp(6)
displayName String?
type String?
country String?
phone String?
overDraftLimit Float? @default(0)
rateEmail String[]
supportEmail String?
Account__fk__ String?
Account Account? @relation(fields: [Account__fk__], references: [id])
Billing__fk__ String?
Billing Billing? @relation(fields: [Billing__fk__], references: [id])
Company__fk__ String?
Company Company? @relation(fields: [Company__fk__], references: [id])
AccountManager__fk__ String?
AccountManager Account? @relation("AccountManager", fields: [AccountManager__fk__], references: [id])
CustomerAccount CustomerAccount[] @relation("CustomerToCustomerAccount")
Invoice Invoice[]
}
model CustomerAccount {
id String @id @unique @default(cuid())
createdAt DateTime @default(now()) @db.Timestamp(6)
updatedAt DateTime @default(now()) @updatedAt @db.Timestamp(6)
displayName String?
Customer__fk__ String?
Customer Customer? @relation("CustomerToCustomerAccount", fields: [Customer__fk__], references: [id], onDelete: Cascade)
Smpp__fk__ String?
Smpp Smpp? @relation(fields: [Smpp__fk__], references: [id])
Rate__fk__ String?
Rate Rate? @relation(fields: [Rate__fk__], references: [id])
Route__fk__ String?
Route Route? @relation(fields: [Route__fk__], references: [id])
Account__fk__ String?
Account Account? @relation(fields: [Account__fk__], references: [id])
}
model Vendor {
id String @id @unique @default(cuid())
createdAt DateTime @default(now()) @db.Timestamp(6)
updatedAt DateTime @default(now()) @updatedAt @db.Timestamp(6)
displayName String?
email String?
technicalEmail String?
country String?
address String?
phone String?
Account__fk__ String?
Account Account? @relation(fields: [Account__fk__], references: [id])
Billing__fk__ String?
Billing Billing? @relation(fields: [Billing__fk__], references: [id])
VendorAccount VendorAccount[]
}
model VendorAccount {
id String @id @unique @default(cuid())
createdAt DateTime @default(now()) @db.Timestamp(6)
updatedAt DateTime @default(now()) @updatedAt @db.Timestamp(6)
displayName String?
Vendor__fk__ String?
Smpp__fk__ String?
Credit__fk__ String?
Rate__fk__ String?
Credit Credit? @relation(fields: [Credit__fk__], references: [id])
Smpp Smpp? @relation(fields: [Smpp__fk__], references: [id])
Vendor Vendor? @relation(fields: [Vendor__fk__], references: [id], onDelete: Cascade)
Rate Rate? @relation(fields: [Rate__fk__], references: [id])
RoutePlan RoutePlan[]
}
model Credit {
id String @id @default(cuid())
createdAt DateTime @default(now()) @db.Timestamp(6)
updatedAt DateTime @default(now()) @db.Timestamp(6)
count String?
limit Int? @default(1)
VendorAccount VendorAccount[]
}
model Route {
id String @id @default(cuid())
createdAt DateTime @default(now()) @db.Timestamp(6)
updatedAt DateTime @default(now()) @db.Timestamp(6)
Account__fk__ String?
displayName String?
type CUSTOMER_TYPE?
status SMPP_STATUS? @default(IN_ACTIVE)
Account Account? @relation(fields: [Account__fk__], references: [id], map: "Route_Account__fk___fkey")
RoutePlan RoutePlan[]
CustomerAccount CustomerAccount[]
}
model RoutePlan {
id String @id @default(cuid())
createdAt DateTime @default(now()) @db.Timestamp(6)
updatedAt DateTime @default(now()) @db.Timestamp(6)
Account__fk__ String?
priority Int? @default(1)
smsType SMS_TYPE? @default(OTP)
isPaused Boolean? @default(true)
Account Account? @relation(fields: [Account__fk__], references: [id], map: "Route_Account__fk___fkey")
VendorAccount VendorAccount[]
Sms Sms[] @relation("RoutePlanToSms")
Route__fk__ String?
Route Route? @relation(fields: [Route__fk__], references: [id], onDelete: Cascade)
Mcc__fk__ String?
Mcc Mcc? @relation(fields: [Mcc__fk__], references: [id])
Mnc__fk__ String?
Mnc Mnc? @relation(fields: [Mnc__fk__], references: [id])
}
model Smpp {
id String @id @unique @default(cuid())
createdAt DateTime @default(now()) @db.Timestamp(6)
updatedAt DateTime @default(now()) @updatedAt @db.Timestamp(6)
displayName String?
isActive Boolean? @default(false)
ip String?
port Int?
username String?
password String?
sessionTimeoutInterval Float? @default(30000)
sessionAllowed Int? @default(1)
tps Int? @default(1)
enquireLinkInterval Float? @default(3000)
maxReconnectAttempts Int? @default(10)
reconnectBackoffFactor Float? @default(2)
initialReconnectDelay Float? @default(1000)
sourceAddress String?
sourceAddressTon Int?
sourceAddressNpi Int?
destinationAddressTon Int?
destinationAddressNpi Int?
trunkType TRUNK_TYPE?
debuggingLevel SMPP_DEBUGGING_LEVEL @default(NONE)
mode SMPP_SESSION_TYPE @default(TRX)
Account__fk__ String?
Logs Logs[]
Account Account? @relation(fields: [Account__fk__], references: [id], onDelete: Cascade)
VendorAccount VendorAccount[]
CustomerAccount CustomerAccount[]
ContentTranslation__fk__ String?
ContentTranslation ContentTranslation? @relation(fields: [ContentTranslation__fk__], references: [id])
}
model Sms {
id String @id @unique @default(cuid())
createdAt DateTime @default(now()) @db.Timestamp(6)
updatedAt DateTime @default(now()) @updatedAt @db.Timestamp(6)
destinationAddress String?
sourceAddress String?
message String?
status SMS_STATUS
type String?
hlrReport Json? @db.Json
registeredDelivery SMPP_REGISTERED_DELIVERY @default(NONE)
RoutePlan RoutePlan[] @relation("RoutePlanToSms")
Invoice Invoice[]
}
model ContentTranslation {
id String @id @unique @default(cuid())
createdAt DateTime @default(now()) @db.Timestamp(6)
updatedAt DateTime @default(now()) @updatedAt @db.Timestamp(6)
regex String?
omitWords String[]
suffix String?
prefix String?
translationKeyword String?
strategy CONTENT_TRANSLATION_STRATERGY?
Smpp Smpp[]
}
model Logs {
id String @id @unique @default(cuid())
createdAt DateTime @default(now()) @db.Timestamp(6)
updatedAt DateTime @default(now()) @updatedAt @db.Timestamp(6)
severity SMPP_DEBUGGING_LEVEL @default(NONE)
output String?
Smpp__fk__ String?
Smpp Smpp? @relation(fields: [Smpp__fk__], references: [id])
}
model Rate {
id String @id @unique @default(cuid())
createdAt DateTime @default(now()) @db.Timestamp(6)
updatedAt DateTime @default(now()) @updatedAt @db.Timestamp(6)
currency String?
Account__fk__ String?
displayName String?
type CUSTOMER_TYPE?
Account Account? @relation(fields: [Account__fk__], references: [id])
RatePlan RatePlan[]
CustomerAccount CustomerAccount[]
VendorAccount VendorAccount[]
}
model RatePlan {
id String @id @unique @default(cuid())
createdAt DateTime @default(now()) @db.Timestamp(6)
updatedAt DateTime @default(now()) @updatedAt @db.Timestamp(6)
smsType String
rate Float
Account__fk__ String?
Rate__fk__ String?
Mcc__fk__ String?
displayName String?
Mcc Mcc? @relation(fields: [Mcc__fk__], references: [id])
Mnc__fk__ String?
Mnc Mnc? @relation(fields: [Mnc__fk__], references: [id])
Account Account? @relation(fields: [Account__fk__], references: [id])
Rate Rate? @relation(fields: [Rate__fk__], references: [id], onDelete: Cascade)
}
model Mcc {
id String @id @unique @default(cuid())
createdAt DateTime @default(now()) @db.Timestamp(6)
updatedAt DateTime @default(now()) @updatedAt @db.Timestamp(6)
mcc String @unique
countryCode String?
countryName String?
countryType String?
RoutePlan RoutePlan[]
RatePlan RatePlan[]
Mnc Mnc[]
}
model Mnc {
id String @id @unique @default(cuid())
createdAt DateTime @default(now()) @db.Timestamp(6)
updatedAt DateTime @default(now()) @updatedAt @db.Timestamp(6)
mnc String
network String
countryCode String?
countryName String?
countryType String?
Mcc__fk__ String?
Mcc Mcc? @relation(fields: [Mcc__fk__], references: [id])
RoutePlan RoutePlan[]
RatePlan RatePlan[]
}
enum PLATFORM_SERVICE_TYPE {
SMPP
SMTP
Service
}
enum ACCOUNT_TYPE {
ACCOUNT_DEFAULT
ACCOUNT_ADMIN
}
enum CUSTOMER_TYPE {
RESELLER
WHOLESALE
TERMINATION
}
enum SMS_STATUS {
NONE
ENROUTE
DELIVERED
EXPIRED
DELETED
UNDELIVERABLE
ACCEPTED
UNKOWN
REJECTED
}
enum SMS_TYPE {
OTP
TRANSACTIONAL
PROMOTIONAL
}
enum SMS_BUILT_TYPE {
FLASH
NORMAL
}
enum BILLING_PERIOD {
SIXTY_DAYS
FIFTEEN_DAYS
SEVEN_DAYS
MONTHLY
TWICE_A_MONTH
}
enum SMPP_STATUS {
ACTIVE
IN_ACTIVE
}
enum CONTENT_TRANSLATION_STRATERGY {
REPLACE
EXTRACT
}
enum SMPP_DEBUGGING_LEVEL {
NONE
ERROR
INFO
DEBUG
ALL
}
enum SMPP_REGISTERED_DELIVERY {
NONE
REQUESTED
REQUESTED_ON_FAILURE
REQUESTED_ON_SUCCESS
}
enum TRUNK_TYPE {
DIRECT
HQ
SIM
SPAM
WHOLESALE
FULLY_FEATURE
SS7
}
enum SMPP_SESSION_TYPE {
TX
RX
TRX
}
Environment & setup
- OS: macOS ( Sanorma )
- Database: PostgreSQL
- Node.js version: 18.0.0
Prisma Version
Reacted by dotsinspace
Metadata
Metadata
Assignees
Labels
bug/1-unconfirmedBug should have enough information for reproduction, but confirmation has not happened yet.kind/bugA reported bug.tech/typescriptIssue for tech TypeScript.topic: performance
Activity
aqrln commentedon Jan 29, 2024
Related: #18292
[-]Prisma object is too heavy.[/-][+]Logging `PrismaClient` object is slow[/+]fix(client): Prevent nodejs from hanging on console.log/util.inspect …
fix(client): Prevent nodejs from hanging on console.log/util.inspect …
janpio commentedon Mar 4, 2024
Hey @dotsinspace, could you please try to temporarily install
prisma@devand@prisma/client@devin your project and see if this fixes the problem? #23228 should have fixed this and will be included in the next release, but of course a confirmation of it now working as intended would be nice.dotsinspace commentedon Mar 9, 2024
i have updated my code with following
and it is working fine now.