question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is there some possibilities to integrate with grpc-web-devtools or chrome devtools?

See original GitHub issue

I was trying something like this:

const transport = new GrpcWebFetchTransport({
  baseUrl: "localhost:3000"
});

const client = new HaberdasheryClient(transport);

const enableDevTools = window.__GRPCWEB_DEVTOOLS__ || (() => {});
enableDevTools([client]);

But I’ve got an error: TypeError: Cannot read properties of undefined (reading 'rpcCall')

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
somedencommented, Sep 8, 2022

Simple example of partial integration with grpc-web-devtools:

interceptors: [
  {
    interceptUnary(next, method, input, options) {
      const call = next(method, input, options);
      const methodFullPath = `${options.baseUrl}/${method.service.typeName}/${method.name}`;
      const methodType = 'unary';

      call.then(
        (finishedUnaryCall) => {
          window.postMessage(
            {
              type: '__GRPCWEB_DEVTOOLS__',
              method: methodFullPath,
              methodType,
              request: finishedUnaryCall.request,
              response: finishedUnaryCall.response,
            },
            '*'
          );

          return finishedUnaryCall;
        },
        (error) => {
          window.postMessage(
            {
              type: '__GRPCWEB_DEVTOOLS__',
              method: methodFullPath,
              methodType,
              request: call.request,
              error: {
                ...error,
                message: error.message,
              },
            },
            '*'
          );
        }
      );

      return call;
    },
    interceptServerStreaming(next, method, input, options) {
      const call = next(method, input, options);
      const methodFullPath = `${options.baseUrl}/${method.service.typeName}/${method.name}`;
      const methodType = 'server_streaming';

      window.postMessage({
        type: '__GRPCWEB_DEVTOOLS__',
        method: methodFullPath,
        methodType,
        request: call.request,
      });

      call.responses.onMessage((message) => {
        window.postMessage(
          {
            type: '__GRPCWEB_DEVTOOLS__',
            method: methodFullPath,
            methodType,
            response: message,
          },
          '*'
        );
      });

      call.responses.onError((error) => {
        window.postMessage(
          {
            type: '__GRPCWEB_DEVTOOLS__',
            method: methodFullPath,
            methodType,
            error: {
              ...error,
              message: error.message,
            },
          },
          '*'
        );
      });

      call.responses.onComplete(() => {
        window.postMessage(
          {
            type: '__GRPCWEB_DEVTOOLS__',
            method: methodFullPath,
            methodType,
            response: 'EOF',
          },
          '*'
        );
      });

      return call;
    },
  },
],
1reaction
timostammcommented, May 18, 2022

grpc-web interceptors are specific to grpc-web. Our interceptors apply to all transports.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SafetyCulture/grpc-web-devtools: Chrome & Firefox ... - GitHub
Chrome & Firefox Browser extension to aid gRPC-Web development - GitHub ... start a simple gRPC server, JavaScript client and the Envoy proxy...
Read more >
gRPC-Web Developer Tools
gRPC -Web Developer Tools is a Chrome DevTools extension for the official gRPC-Web library. It allows you to inspect the gRPC network log...
Read more >
Debugging gRPC-Web with Custom Chrome Developer Tools
Collect and display all gRPC-Web network requests and responses in a list. · Chrome Developer Tools extension for the official gRPC-Web library.
Read more >
The state of gRPC in the browser
The Google gRPC-Web client is implemented in JavaScript using the Google Closure library base. It is available on npm as grpc-web. It originally ......
Read more >
gRPC-web: Using gRPC in Your Front-End Application - Torq
gRPC-web is a JavaScript implementation of gRPC for browser clients. It gives you all the advantages of working with gRPC, such as efficient ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found