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.

TypeError: b is not a function. (In 'b(null, d)', 'b' is undefined)

See original GitHub issue

Hi there,

I’m having some issues invoking gRPC-web calls from my React application. Invoking my RPC works correctly and the server receives the request without issue, however an error appears in my console on every request.

index.js:60 Uncaught TypeError: b is not a function
    at Array.<anonymous> (index.js:60)
    at yc (index.js:53)
    at S.<anonymous> (index.js:51)
    at Ib (index.js:34)
    at O (index.js:33)
    at oc (index.js:42)
    at S.push../node_modules/grpc-web/index.js.S.O (index.js:40)
    at S.push../node_modules/grpc-web/index.js.S.K (index.js:40)

I’m running a gRPC server in Go with a React application communicating with the Go server via the Envoy proxy.

I compile my Proto using the following command:

protoc \
		--js_out=import_style=commonjs,binary:web-client/src/ \
		--grpc-web_out=import_style=commonjs,mode=grpcwebtext:web-client/src/ \
		proto/myapp.proto
$ protoc --version
libprotoc 3.14.0

and I build my request from React like so:

const { GetMessagesRequest, Message } = require('../../proto/myapp_pb.js');
const { MyappClient } = require('../../proto/myapp_grpc_web_pb');

const myappService = new MyappClient('http://localhost:8080');
const msg = new Message()

const meta = {
    "authorization": "fake_123456",
  }

await myappService.broadcast(msg, meta)

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:2
  • Comments:7

github_iconTop GitHub Comments

6reactions
alertedsnakecommented, Feb 25, 2021

My coworker found the issue here - before, my call looked like this:

function doCall() {
  return new Promise((resolve, reject) => {
        client.rpcCall(request)
            .on("data", () => resolve())
            .on("status", () => {})
            .on("error", response => reject(response.message));
   });
}

But now it needs to look like:

function doCall() {
  return new Promise((resolve, reject) => {
        client.rpcCall(request, null, (err, response) => {
            if (err) {
                reject(err.message);
            }
            else {
                resolve();
            }
        });
   });
}

Hopefully this may help you as well.

1reaction
alertedsnakecommented, Mar 8, 2022

@Enrikerf oh - I’m FAR from the right person to be asking, I do very little Javascript, not sure I can really help much 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: b is undefined when appending - Stack Overflow
You call styleBox without setting this reference, you need to do styleBox.apply(this) $("#invite-emails").keypress(function(e){ if(e.which ...
Read more >
Uncaught TypeError: 'undefined' is not a function
Uncaught TypeError: 'undefined' is not a function. This is a common JavaScript error that happens when you try to call a function before...
Read more >
TypeError: "x" is not a function - JavaScript - MDN Web Docs
The JavaScript exception "is not a function" occurs when there was an attempt to call a value from a function, but the value...
Read more >
How to Handle JavaScript Uncaught TypeError: “x” is Not a ...
The Javascript TypeError: "x" is not a function occurs when calling a function on a value or object, which is not actually a...
Read more >
The 10 Most Common JavaScript Issues Developers Face
Haskel: ``` add a b = a + b add5 = add 5 ``` JavaScript: ``` function add(a,b) { return a+b } var...
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