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

Introspection query causes memory leaks with Remix, drizzle, pg #3624

Open
oh-jinsu opened this issue Jan 8, 2025 · 1 comment
Open

Introspection query causes memory leaks with Remix, drizzle, pg #3624

oh-jinsu opened this issue Jan 8, 2025 · 1 comment

Comments

@oh-jinsu
Copy link

oh-jinsu commented Jan 8, 2025

Describe the bug

I've been using graphql-yoga with Remix, Drizzle, and Vercel Postgres, and my initial setup looked like this:

import { sql } from "vercel/postgres";
import { drizzle } from "drizzle-orm/vercel-postgres";
import * as schema from "./schema";
import { buildSchema } from "drizzle-graphql";

const db = drizzle(sql, { schema });

const graphqlSchema = buildSchema(db);

const yoga = createYoga({
  schema: graphqlSchema ,
  graphqlEndpoint: "/api/graphql",
});

export const loader = ({ request, context }: LoaderFunctionArgs) => yoga.handleRequest(request, context);

export const action = ({ request, context }: ActionFunctionArgs) => yoga.handleRequest(request, context);

Recently, I switched from Vercel DB to a local PostgreSQL database like this:

import { drizzle } from "drizzle-orm/node-postgres";
import pg from "pg";

const pool = new pg.Pool({
  host: process.env.POSTGRES_HOST!,
  port: parseInt(process.env.POSTGRES_PORT!),
  user: process.env.POSTGRES_USER!,
  password: process.env.POSTGRES_PASSWORD!,
  database: process.env.POSTGRES_DATABASE!,
});

const db = drizzle(pool, { schema });

// same below

However, after making this change, the server crashes with a JavaScript heap out of memory error whenever I send a query request. After debugging, I found out that introspection queries (as well as other POST requests) hang forever in yoga GraphiQL.

So I added the useDisableIntrospection() plugin from @graphql-yoga/plugin-disable-introspection, and that resolved the issue.

I'm figuring out why it happens because I want to keep using yoga, but help needed please.

Your Example Website or App

https://codesandbox.io/p/devbox/holy-rain-k8dd7t?file=%2Fsrc%2Fapi.graphql.ts%3A19%2C4

Steps to Reproduce the Bug or Issue

  1. Set up graphql yoga with remix, drizzle, pg.
  2. Send query request

Expected behavior

The introspection should work well without memory issue.

Screenshots or Videos

No response

Platform

  • OS: Window, Linux
  • NodeJS: 20.13.1
  • @graphql-yoga/* version(s): 5.10.9

Additional context

No response

@ardatan
Copy link
Collaborator

ardatan commented Jan 8, 2025

Thank you for creating the issue./
I guess the CodeSandbox you shared doesn't include Remix setup, so could you update it so we can reproduce the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants