convex-backend icon indicating copy to clipboard operation
convex-backend copied to clipboard

Dynamic require of "stream" is not supported

Open thewbuk opened this issue 9 months ago • 2 comments

import { headers } from "next/headers";
import Stripe from "stripe";
import { ConvexHttpClient } from "convex/browser";
import { stripe } from "@/lib/stripe";
import { env } from "process";
import { api } from "../../../../../convex/_generated/api";

const convex = new ConvexHttpClient(process.env.NEXT_PUBLIC_CONVEX_URL!);

export async function POST(req: Request) {
  const body = await req.text();

  const signature = headers().get("Stripe-Signature") as string;

  if (!env.STRIPE_WEBHOOK_SECRET) {
    return new Response("Missing STRIPE_WEBHOOK_SECRET", { status: 500 });
  }

  let event: Stripe.Event;

throws

Call Stack
eval
node_modules\.pnpm\[email protected]_@[email protected][email protected][email protected][email protected]__react-do_a6pe3624vgfhu2tivlhxgo7czi\node_modules\convex\dist\esm\browser\simple_client-node.js (12:1)
../common/temp/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/ws/lib/stream.js
node_modules\.pnpm\[email protected]_@[email protected][email protected][email protected][email protected]__react-do_a6pe3624vgfhu2tivlhxgo7czi\node_modules\convex\dist\esm\browser\simple_client-node.js (38:20)

thewbuk avatar Feb 03 '25 16:02 thewbuk

Ok fixed it by changing to:

   const response = await fetch(
      `${process.env.NEXT_PUBLIC_CONVEX_URL}/api/query?path=users:getUserByClerkId`,
      {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
        },
        body: JSON.stringify({
          args: { clerkId: userId },
        }),
      }
    );

I'll leave the ticket open as the issue stands with the package

thewbuk avatar Feb 03 '25 16:02 thewbuk

More specific repro steps would be appreciated! If you could make a little repo that reproes the issue and link it, that would be best.

nipunn1313 avatar Apr 24 '25 18:04 nipunn1313