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

Fix data proxy unsupported before exit event #8274

Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions packages/core/src/lib/createSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,17 @@ export function createSystem(config: KeystoneConfig) {

setWriteLimit(prismaClient, pLimit(config.db.provider === 'sqlite' ? 1 : Infinity));
setPrismaNamespace(prismaClient, prismaModule.Prisma);
prismaClient.$on('beforeExit', async () => {
// Prisma is failing to properly clean up its child processes
// https://github.com/keystonejs/keystone/issues/5477
// We explicitly send a SIGINT signal to the prisma child process on exit
// to ensure that the process is cleaned up appropriately.
prismaClient._engine.child?.kill('SIGINT');
});

// beforeExit event is not supported by Prisma Data Proxy
if (!prismaClient._dataProxy) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm accessing the internal variable prismaClient._dataProxy here because the only alternative to check for dataProxy usage would be:

prismaClient.getEngine().constructor.name === 'DataProxyEngine'

prismaClient.$on('beforeExit', async () => {
// Prisma is failing to properly clean up its child processes
// https://github.com/keystonejs/keystone/issues/5477
// We explicitly send a SIGINT signal to the prisma child process on exit
// to ensure that the process is cleaned up appropriately.
prismaClient._engine.child?.kill('SIGINT');
});
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we actually need this still?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am unable to replicate the original issue (#5477) if I remove this whole prismaClient.$on block

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's drop it


const context = makeCreateContext({
graphQLSchema,
Expand Down