dapr / js-sdk

Dapr SDK for Javascript
Apache License 2.0
194 stars 82 forks source link

Error when instantiatiating DaprClient (TS) #550

Closed umerkle closed 10 months ago

umerkle commented 10 months ago

Expected Behavior

No error in Browser console

Actual Behavior

When instantiating a DaprClient, i get the following error in Browser console:

TypeError: Class extends value undefined is not a constructor or null at node_modules/@grpc/grpc-js/build/src/call.js (call.ts:88:11) at require2 (chunk-OROXOI2D.js?v=e658d520:16:50) at node_modules/@grpc/grpc-js/build/src/client.js (client.ts:18:1) at __require2 (chunk-OROXOI2D.js?v=e658d520:16:50) at node_modules/@grpc/grpc-js/build/src/make-client.js (make-client.ts:20:1) at require2 (chunk-OROXOI2D.js?v=e658d520:16:50) at node_modules/@grpc/grpc-js/build/src/channelz.js (channelz.ts:60:1) at __require2 (chunk-OROXOI2D.js?v=e658d520:16:50) at node_modules/@grpc/grpc-js/build/src/subchannel.js (subchannel.ts:30:1) at __require2 (chunk-OROXOI2D.js?v=e658d520:16:50)

Steps to Reproduce the Problem

Use node v20.9.0, npm 10.2.3 (in my case on linux)

I have a Vue3 (3.3.8) app setup with Quasar. For this, i installed Quasar as described in the docu:

Install @dapr/dapr (or @dapr/dapr-dev)

My component instantiates a DaprClient like this:

<script lang="ts">
import { defineComponent, ref } from 'vue';
import {
  DaprClient,
  HttpMethod,
  CommunicationProtocolEnum,
} from '@dapr/dapr-dev';

onst daprHost = '127.0.0.1'; // Dapr Sidecar Host
const daprPort = '3500'; // Dapr Sidecar Port of this Example Server
const serverHost = '127.0.0.1'; // App Host of this Example Server
const serverPort = '50051'; // App Port of this Example Server

export default defineComponent({
  setup() {
    runFullCheck(): void {
        alert('Full check');

        const daprClient = new DaprClient({
          daprHost,
          daprPort,
          communicationProtocol: CommunicationProtocolEnum.HTTP,
        });
      },
  }
});
</script>

Run the app with: npx quasar dev

When commenting out const daprClient = new DaprClient ..., everything is OK.

shubham1172 commented 10 months ago

Hi, the Dapr SDK is not supported to be run on Browsers. Only server-side node environments.