tl;dr
tl;dr
PPrisma
Created by simnJS on 8/5/2024 in #help-and-questions
Issue with prisma optimize
It ended up working with mssql in a simple setup too, but still not in my original repository. So I started tearing my original repository apart to find out what was different, and while doing that, I discovered what caused the slow requests I had in the first place. Still didn't get optimize to work there though :/.
26 replies
PPrisma
Created by simnJS on 8/5/2024 in #help-and-questions
Issue with prisma optimize
@Nurul Thanks for getting back 👍. It didn't for two days. but then I tried this morning, and now it works perfectly (https://github.com/nurul3101/Optimize-NestJS/issues/2#issuecomment-2440944354) 😊. I'm still trying to track down an issue in my original setup which is a bit different (first of all running mssql), so I'm trying to dig into it a little deeper.
26 replies
PPrisma
Created by simnJS on 8/5/2024 in #help-and-questions
Issue with prisma optimize
Hi @Nurul (Prisma), I tried your repo, is it still working on your end :)? Is there something about generating the keys that I need to be aware of? Cheers! (https://github.com/nurul3101/Optimize-NestJS/issues/2)
26 replies
PPrisma
Created by Txt on 9/25/2024 in #help-and-questions
NestJs + Prisma Optimize
I guess theres no open issue, thanks for the efford. out.
31 replies
PPrisma
Created by Txt on 9/25/2024 in #help-and-questions
NestJs + Prisma Optimize
Time better spend looking into the performance issues in another way.
31 replies
PPrisma
Created by Txt on 9/25/2024 in #help-and-questions
NestJs + Prisma Optimize
It would be too time consuming to begin to pull the app appart etc., and with no guarantee of a positive outcome, I can't make that investment unfortunately :/.
31 replies
PPrisma
Created by Txt on 9/25/2024 in #help-and-questions
NestJs + Prisma Optimize
Hmm, I guess I'm going to have to bail on this then :/.. Is there an open issue somewhere I can follow so I can get back to this at some point?
31 replies
PPrisma
Created by Txt on 9/25/2024 in #help-and-questions
NestJs + Prisma Optimize
This is my service:
TypeScript
import { Injectable, Logger, OnModuleInit } from '@nestjs/common';
import { from } from 'rxjs';
import { PrismaClient } from '@prisma-types/farm';
import { withOptimize } from '@prisma/extension-optimize';
import { ConfigService } from '@nestjs/config';

@Injectable()
export class PrismaMainMSClient extends PrismaClient implements OnModuleInit {
private readonly logger: Logger = new Logger(`PrismaMainMSClient`);

constructor(
private configService: ConfigService,
) {
super();

// Attempt to disconnect Prisma when server is interrupted
process.on('SIGINT', (): void => {
from(
this.$disconnect(),
)
.subscribe({
next: (): void => {
this.logger.log(`\tPrisma Client disconnected`);
process.exit(0);
},
error: (): void => {
this.logger.error(`\tPrisma Client failed to disconnect!`);
process.exit(1);
},
});
});

}

/**
*
*/
public async onModuleInit(

): Promise<void> {
const customPrismaClient: any = new PrismaClient()
.$extends(
withOptimize({ apiKey: this.configService.getOrThrow('OPTIMIZE_API_KEY') }),
);

Object.assign(this, customPrismaClient);

await this.$connect();

console.log('Database initialized!');
}
}
TypeScript
import { Injectable, Logger, OnModuleInit } from '@nestjs/common';
import { from } from 'rxjs';
import { PrismaClient } from '@prisma-types/farm';
import { withOptimize } from '@prisma/extension-optimize';
import { ConfigService } from '@nestjs/config';

@Injectable()
export class PrismaMainMSClient extends PrismaClient implements OnModuleInit {
private readonly logger: Logger = new Logger(`PrismaMainMSClient`);

constructor(
private configService: ConfigService,
) {
super();

// Attempt to disconnect Prisma when server is interrupted
process.on('SIGINT', (): void => {
from(
this.$disconnect(),
)
.subscribe({
next: (): void => {
this.logger.log(`\tPrisma Client disconnected`);
process.exit(0);
},
error: (): void => {
this.logger.error(`\tPrisma Client failed to disconnect!`);
process.exit(1);
},
});
});

}

/**
*
*/
public async onModuleInit(

): Promise<void> {
const customPrismaClient: any = new PrismaClient()
.$extends(
withOptimize({ apiKey: this.configService.getOrThrow('OPTIMIZE_API_KEY') }),
);

Object.assign(this, customPrismaClient);

await this.$connect();

console.log('Database initialized!');
}
}
`
31 replies
PPrisma
Created by Txt on 9/25/2024 in #help-and-questions
NestJs + Prisma Optimize
No description
31 replies
PPrisma
Created by Txt on 9/25/2024 in #help-and-questions
NestJs + Prisma Optimize
And I have my server running localhost making queries ofc.
31 replies
PPrisma
Created by Txt on 9/25/2024 in #help-and-questions
NestJs + Prisma Optimize
When I go to the UI on https://optimize.prisma.io, theres just nothing comming in.
31 replies
PPrisma
Created by Txt on 9/25/2024 in #help-and-questions
NestJs + Prisma Optimize
Yes unfortunately, it's a commercial product :/. Is there a way to check from my localhost, if I even reach the Prisma backend for the optimize service?
31 replies
PPrisma
Created by Txt on 9/25/2024 in #help-and-questions
NestJs + Prisma Optimize
Any updates on this?
31 replies
PPrisma
Created by Txt on 9/25/2024 in #help-and-questions
NestJs + Prisma Optimize
I have the same issue, and the suggested code doesn't work for me either :).
31 replies