-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mountebank-grpc:imposter load - failed @ protobufjs/src/root.js #3
Comments
Hi @mukrisp , I see the problem. I'll comment on a few things though since it looks like you're trying to get this to work 😄.
That property was accidentally being sent to root.js.
Let me know if you have any other problems. There are some limitations with this implementation with the WellKnownTypes, but if you don't need those these are good for a quick mock. |
Hi, Thanks for looking into this. As per your suggestion updated the imposter config by excluding the "_note" param. Regards, |
Hi,
I am using mountebank with grpc provided in this git
https://github.com/cbrz/mountebank-grpc
Loading imposter is failing with error in mb console. Please find below the error output,
MB_CONSOLE_LOG:
[ root@86a565a751fb:/usr/lib/node_modules/mountebank/mountebank-grpc {master } ]$ mb start --protofile protocols.json --loglevel debug
info: [mb:2525] Loaded custom protocol grpc
info: [mb:2525] mountebank v2.1.2 now taking orders - point your browser to http://localhost:2525/ for help
debug: [mb:2525] config: {"options":{"protofile":"protocols.json","loglevel":"debug","port":2525,"noParse":false,"no-parse":false,"pidfile":"mb.pid","nologfile":false,"logfile":"mb.log","allowInjection":false,"allow-injection":false,"localOnly":false,"local-only":false,"ipWhitelist":[""],"ip-whitelist":"*","mock":false,"debug":false,"heroku":false},"process":{"nodeVersion":"v13.7.0","architecture":"x64","platform":"linux"}}
info: [mb:2525] POST /imposters
debug: [mb:2525] ::ffff:127.0.0.1:43380 => {"protocol":"grpc","port":4545,"loglevel":"debug","recordRequests":true,"services":{"_note":"need the name of the service and protofile location for this to load","example.ExampleService":{"file":"/usr/lib/node_modules/mountebank/mountebank-grpc/src/protos/example.proto"}},"options":{"protobufjs":{"_note":"any options to protobufjs","includeDirs":["/usr/lib/node_modules/mountebank/mountebank-grpc/src/protos"]}},"stubs":[{"predicates":[{"matches":{"path":"UnaryUnary"},"caseSensitive":false}],"responses":[{"is":{"value":{"_note":"gRPC mock unary call response","_note_streaming":"this is a unary/unary call, streaming requests need the value to be an array","id":100,"data":"mock response"},"metadata":{"_note":"gRPC mock initial/trailing metadata response","initial":{"metadata-initial-key":"metadata-initial-value"},"trailing":{"metadata-trailing-key":"metadata-trailing-value"}},"error":{"_note":"gRPC mock error","status":"OUT_OF_RANGE","message":"invalid message"}}}]}]}
info: [grpc:4545] Open for business...
error: [grpc:4545] /usr/lib/node_modules/mountebank/mountebank-grpc/node_modules/protobufjs/src/root.js:193
for (var i = 0, resolved; i < filename.length; ++i)
^
TypeError: Cannot read property 'length' of undefined
at Root.load (/usr/lib/node_modules/mountebank/mountebank-grpc/node_modules/protobufjs/src/root.js:193:44)
at Root.loadSync (/usr/lib/node_modules/mountebank/mountebank-grpc/node_modules/protobufjs/src/root.js:236:17)
at Object.loadSync (/usr/lib/node_modules/mountebank/mountebank-grpc/node_modules/@grpc/proto-loader/build/src/index.js:221:27)
at Object.getServiceDefinition (/usr/lib/node_modules/mountebank/mountebank-grpc/src/grpc/service.js:38:36)
at /usr/lib/node_modules/mountebank/mountebank-grpc/src/mock.js:35:41
at Array.forEach ()
at Object.getServerInstance (/usr/lib/node_modules/mountebank/mountebank-grpc/src/mock.js:32:37)
at Server. (/usr/lib/node_modules/mountebank/mountebank-grpc/src/index.js:23:41)
at Object.onceWrapper (events.js:427:28)
at Server.emit (events.js:321:20)
error: [grpc:4545] Uh oh! I've crashed! Expect subsequent requests to fail.
IMPOSTER_LOAD_COMMAND:
[ root@86a565a751fb:/usr/lib/node_modules/mountebank/mountebank-grpc {master *} ]$ curl -X POST -d @mb_grpc_templates.ejs http://localhost:2525/imposters --header "Content-Type:application/json"
{
"errors": [
{
"code": "cannot start server",
"message": ""grpc" start command failed (exit code 1)",
"source": "node /usr/lib/node_modules/mountebank/mountebank-grpc/src/index.js",
"domainThrown": true
}
]
}[ root@86a565a751fb:/usr/lib/node_modules/mountebank/mountebank-grpc {master *} ]$
Tried to add debug in protobufjs/src/root.js by adding arguments print in console, mountebank is crashing during imposter load now.
error: [grpc:4545] /usr/lib/node_modules/mountebank/mountebank-grpc/node_modules/protobufjs/src/root.js:193
Root.prototype.load = function load(filename, options, callback) {
console.log(arguments); << added this line for debugging
if (typeof options === "function") {
IMPOSTER_CONTENT:
[ root@86a565a751fb:/usr/lib/node_modules/mountebank/mountebank-grpc {master *} ]$ cat /usr/lib/node_modules/mountebank/mountebank-grpc/mb_grpc_templates.ejs
{
"protocol": "grpc",
"port": 4545,
"loglevel": "debug",
"recordRequests": true,
"services": {
"_note": "need the name of the service and protofile location for this to load",
"example.ExampleService": {
"file": "/usr/lib/node_modules/mountebank/mountebank-grpc/src/protos/example.proto"
}
},
"options": {
"protobufjs": {
"_note": "any options to protobufjs",
"includeDirs": ["/usr/lib/node_modules/mountebank/mountebank-grpc/src/protos"]
}
},
"stubs": [{
"predicates": [
{
"matches": { "path": "UnaryUnary" },
"caseSensitive": false
}
],
"responses": [
{
"is": {
"value": {
"_note": "gRPC mock unary call response",
"_note_streaming": "this is a unary/unary call, streaming requests need the value to be an array",
"id": 100,
"data": "mock response"
},
"metadata": {
"_note": "gRPC mock initial/trailing metadata response",
"initial": {
"metadata-initial-key": "metadata-initial-value"
},
"trailing": {
"metadata-trailing-key": "metadata-trailing-value"
}
},
"error": {
"_note": "gRPC mock error",
"status": "OUT_OF_RANGE",
"message": "invalid message"
}
}
}
]
}]
}
[ root@86a565a751fb:/usr/lib/node_modules/mountebank/mountebank-grpc {master *} ]$
MOUNTEBANK_GRPC_PRTOCOLS_FILE_CONTENT:
[ root@86a565a751fb:/usr/lib/node_modules/mountebank/mountebank-grpc {master *} ]$ cat /usr/lib/node_modules/mountebank/mountebank-grpc/protocols.json
{
"grpc": {
"createCommand": "node /usr/lib/node_modules/mountebank/mountebank-grpc/src/index.js"
}
}
[ root@86a565a751fb:/usr/lib/node_modules/mountebank/mountebank-grpc {master *} ]$
/usr/lib/node_modules/mountebank/mountebank-grpc/src/index.js << content https://github.com/cbrz/mountebank-grpc/blob/master/src/index.js
Thanks and Regards,
Muthukrishnan.P
The text was updated successfully, but these errors were encountered: