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.

Uncaught TypeError: o.toArray is not a function

See original GitHub issue

Hi!

I try to work with any.proto

syntax = "proto3";
import "google/protobuf/any.proto";
...
message AddJobRequest {
	string api_key = 1;
	int32 token_id = 2;
	JobAction action = 3;
	google.protobuf.Any payload = 4;
}

I compile proto under Windows with command

protoc --plugin=protoc-gen-grpc-web=protoc-gen-grpc-web-1.0.3-windows-x86_64.exe --grpc-web_out=out=Job_grpc_web_pb.js,import_style=commonjs,mode=grpcweb:JS_Campaigns Job.proto

and pack with

npx webpack client.js

My function is:

function addNewJob(api_key, token_id, action, payload, callback) {
	
	var request = new AddJobRequest();
	request.setApiKey(api_key);
	request.setTokenId(token_id);
	request.setAction(action);
	request.setPayload({ payload: payload });
	
	job_client.addNew(request, metadata, (err, response) => {
		callback(response, err);
	});	
	
}

I receive error

Uncaught TypeError: o.toArray is not a function

The same error occurs with google/protobuf/wrappers.proto What I’m doing wrong?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:6

github_iconTop GitHub Comments

1reaction
mfecteau34commented, Mar 25, 2019

It’s difficult to tell why you have “proto” as undefined without looking at all your “client.js” script. For my part, just by following the basic “helloworld” example, I got this “proto” variable in my globals.

If it could help you : I was able to get some inspiration by looking at this example. Though I didn’t follow the example step by step, it was by looking at it that I discoved that there was a “fromJavaScript” function (and also a “toJavaScript”) to convert JSON to Struct.proto (and vice-versa).

0reactions
stanley-cheungcommented, May 7, 2020

Sorry I have to declare Bug Bankruptcy on some of these older bugs. But this looks like a protobuf issue. If this is still a grpc-web issue, please open a new one.

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - .toArray(); is not a function - Stack Overflow
The issue is you have to create a new marker. If you follow the code in the documentation it should work. Try the...
Read more >
How to solve 'TypeError: db.find(…).toArray is not a function' in ...
The toArray function exists on the Cursor class from the Native MongoDB NodeJS driver. The find method in MongooseJS returns a Query object....
Read more >
TypeError error: _toArray is not a function. - GSAP - GreenSock
I tried to make this slide in Rickett to learn: I get a TypeError error: _toArray is not a function.
Read more >
this.get(...).toArray is not a function(…)-ember.js - appsloveworld
Coding example for the question Uncaught TypeError: this.get(. ... You're not alone in struggling with this, as I've been seeing a large number...
Read more >
TypeError: find is not a function in JavaScript | bobbyhadz
The "find is not a function" error occurs when we call the find() method on a value that is not of type array....
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