Skip to content

ReferenceError: self is not defined #579

Closed
@majian159

Description

@majian159

Expected Behavior

Actual Behavior

I encountered the following error while using the Dapr JS SDK in Next.js:

node_modules/.pnpm/[email protected]/node_modules/google-protobuf/google-protobuf.js (12:313) @ self
 ⨯ ReferenceError: self is not defined
    at eval (webpack-internal:///(rsc)/./node_modules/.pnpm/[email protected]/node_modules/google-protobuf/google-protobuf.js:97:27)
    at (rsc)/./node_modules/.pnpm/[email protected]/node_modules/google-protobuf/google-protobuf.js (/Users/majian/Source/jkzl/tutu-langchain/.next/server/vendor-chunks/[email protected]:20:1)
    at __webpack_require__ (/Users/majian/Source/jkzl/tutu-langchain/.next/server/webpack-runtime.js:33:43)
    at eval (webpack-internal:///(rsc)/./node_modules/.pnpm/[email protected]/node_modules/google-protobuf/google/protobuf/any_pb.js:11:12)

code:

import { DaprClient } from "@dapr/dapr";
import { NextResponse, type NextRequest } from "next/server";

export async function GET(request: NextRequest) {
  const daprHost = "127.0.0.1";
  const daprPort = "3500";

  const client = new DaprClient({ daprHost, daprPort });
  const response = await client.state.save("statestore", [
    { key: "key", value: "value" },
  ]);
  console.info(response);

  return NextResponse.json({});
}

Steps to Reproduce the Problem

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions