grpc-web-devtools icon indicating copy to clipboard operation
grpc-web-devtools copied to clipboard

Make use of grpc-web interceptor

Open jvmlet opened this issue 5 years ago • 8 comments
trafficstars

Now, when grpc-web officially supports interceptors , would be great to see this extension uses them.

jvmlet avatar Jun 30 '20 10:06 jvmlet

BTW, improbable also supports interceptors, so all users might benefit from this great dev tool.

jvmlet avatar Jun 30 '20 10:06 jvmlet

Yea; this is something that I would like to get to doing at some point. Happy for PRs if someone has the time to look into this?

rogchap avatar Aug 01 '20 23:08 rogchap

pull request for interceptors https://github.com/SafetyCulture/grpc-web-devtools/pull/79

jrapoport avatar Dec 13 '20 08:12 jrapoport

merged this change into my fork's master and updated the readme to reflect the change. I'm dropping a link here for anyone that finds this and wants to use native gRPC-Web interceptors: https://github.com/jrapoport/grpc-web-devtools

jrapoport avatar Jan 11 '21 20:01 jrapoport

@jrapoport So does your version work with https://github.com/improbable-eng/grpc-web? If so, do you need to do anything to make sure that the browser has a specific version of devtools (which supports one client library over the other) installed?

caseylucas avatar Mar 10 '21 13:03 caseylucas

no clue. it was written for https://github.com/grpc/grpc-web interceptors. the version i wrote isn't published so you have to install manually and disable other versions.

it might work with improbable interceptors if they are functionally the same, but i've never tried it.

jrapoport avatar Mar 10 '21 19:03 jrapoport

The following code works for me for improbable-eng

import { grpc } from '@improbable-eng/grpc-web'

...

grpc.unary(methodDescriptor, {
        request: request,
        host: backendURL,
        metadata: new grpc.Metadata(metadata),
        onEnd: res => {
          const { status, statusMessage, headers, message, trailers } = res

          window.postMessage({
            type: '__GRPCWEB_DEVTOOLS__',
            method: methodDescriptor.service.serviceName + '/' + methodDescriptor.methodName,
            methodType: 'unary',
            request: request.toObject(),
            response: message.toObject(),
          }, '*')
       }
    }
 )   

gebv avatar Mar 09 '23 00:03 gebv

Created this PR with several lines of code to fix this issue.

nibres avatar Mar 11 '23 23:03 nibres