{"action":"created","issue":{"url":"https://api.github.com/repos/protocolbuffers/protobuf/issues/5162","repository_url":"https://api.github.com/repos/protocolbuffers/protobuf","labels_url":"https://api.github.com/repos/protocolbuffers/protobuf/issues/5162/labels{/name}","comments_url":"https://api.github.com/repos/protocolbuffers/protobuf/issues/5162/comments","events_url":"https://api.github.com/repos/protocolbuffers/protobuf/issues/5162/events","html_url":"https://github.com/protocolbuffers/protobuf/issues/5162","id":361085944,"node_id":"MDU6SXNzdWUzNjEwODU5NDQ=","number":5162,"title":"Messages with wrappers throw an error at jspb.Message.setWrapperField when making client requests","user":{"login":"SadieF","id":34973153,"node_id":"MDQ6VXNlcjM0OTczMTUz","avatar_url":"https://avatars1.githubusercontent.com/u/34973153?v=4","gravatar_id":"","url":"https://api.github.com/users/SadieF","html_url":"https://github.com/SadieF","followers_url":"https://api.github.com/users/SadieF/followers","following_url":"https://api.github.com/users/SadieF/following{/other_user}","gists_url":"https://api.github.com/users/SadieF/gists{/gist_id}","starred_url":"https://api.github.com/users/SadieF/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SadieF/subscriptions","organizations_url":"https://api.github.com/users/SadieF/orgs","repos_url":"https://api.github.com/users/SadieF/repos","events_url":"https://api.github.com/users/SadieF/events{/privacy}","received_events_url":"https://api.github.com/users/SadieF/received_events","type":"User","site_admin":false},"labels":[{"id":124699531,"node_id":"MDU6TGFiZWwxMjQ2OTk1MzE=","url":"https://api.github.com/repos/protocolbuffers/protobuf/labels/bug","name":"bug","color":"fc2929","default":true},{"id":325308401,"node_id":"MDU6TGFiZWwzMjUzMDg0MDE=","url":"https://api.github.com/repos/protocolbuffers/protobuf/labels/javascript","name":"javascript","color":"bfe5bf","default":false}],"state":"open","locked":false,"assignee":{"login":"TeBoring","id":5195749,"node_id":"MDQ6VXNlcjUxOTU3NDk=","avatar_url":"https://avatars1.githubusercontent.com/u/5195749?v=4","gravatar_id":"","url":"https://api.github.com/users/TeBoring","html_url":"https://github.com/TeBoring","followers_url":"https://api.github.com/users/TeBoring/followers","following_url":"https://api.github.com/users/TeBoring/following{/other_user}","gists_url":"https://api.github.com/users/TeBoring/gists{/gist_id}","starred_url":"https://api.github.com/users/TeBoring/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TeBoring/subscriptions","organizations_url":"https://api.github.com/users/TeBoring/orgs","repos_url":"https://api.github.com/users/TeBoring/repos","events_url":"https://api.github.com/users/TeBoring/events{/privacy}","received_events_url":"https://api.github.com/users/TeBoring/received_events","type":"User","site_admin":false},"assignees":[{"login":"TeBoring","id":5195749,"node_id":"MDQ6VXNlcjUxOTU3NDk=","avatar_url":"https://avatars1.githubusercontent.com/u/5195749?v=4","gravatar_id":"","url":"https://api.github.com/users/TeBoring","html_url":"https://github.com/TeBoring","followers_url":"https://api.github.com/users/TeBoring/followers","following_url":"https://api.github.com/users/TeBoring/following{/other_user}","gists_url":"https://api.github.com/users/TeBoring/gists{/gist_id}","starred_url":"https://api.github.com/users/TeBoring/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TeBoring/subscriptions","organizations_url":"https://api.github.com/users/TeBoring/orgs","repos_url":"https://api.github.com/users/TeBoring/repos","events_url":"https://api.github.com/users/TeBoring/events{/privacy}","received_events_url":"https://api.github.com/users/TeBoring/received_events","type":"User","site_admin":false}],"milestone":null,"comments":2,"created_at":"2018-09-17T23:55:12Z","updated_at":"2018-09-25T08:13:27Z","closed_at":null,"author_association":"NONE","body":"Hi there,\r\nWe are trying to make a request to our gRPC service from a React Client. The Unary request works fine with normal message fields, however on message fields that have wrappers around them, we get this error: \r\n```\r\nTypeError: c.toArray is not a function\r\nFunction../node_modules/google-protobuf/google-protobuf.js.jspb.Message.setWrapperField\r\n```\r\n\r\nRelating to this function:\r\n\r\n```\r\n /** @param {?proto.google.protobuf.Int64Value|undefined} value */\r\n proto.api.ListRequest.prototype.setLimit = function(value) {\r\n   jspb.Message.setWrapperField(this, 1, value);\r\n};\r\n\r\njspb.Message.wrapRepeatedField_=function(a,b,c){a.wrappers_||(a.wrappers_={});if(!a.wrappers_[c]){for(var d=jspb.Message.getRepeatedField(a,c),e=[],f=0;f<d.length;f++)e[f]=new b(d[f]);a.wrappers_[c]=e}};jspb.Message.setWrapperField=function(a,b,c){a.wrappers_||(a.wrappers_={});var d=c?c.toArray():c;a.wrappers_[b]=c;jspb.Message.setField(a,b,d)};\r\n\r\n```\r\n\r\n\r\nOur gRPC service and request messages are set up like so:\r\n```\r\n  rpc List(ListRequest) returns (ListResponse) {\r\n     option (google.api.http) = {\r\n      get: \"/v3/items\"\r\n    };\r\n  }\r\n\r\nmessage ListRequest {\r\n  google.protobuf.Int64Value limit = 1;\r\n  google.protobuf.StringValue name = 2;\r\n  google.protobuf.BoolValue isActive = 3;\r\n  QueryMeta Meta = 100;\r\n}\r\n\r\nmessage QueryMeta {\r\n  string cursor = 1;\r\n}\r\n\r\n```\r\n\r\nAnd we are sending the request from the client like this:\r\n\r\n```\r\n    const query = new ListRequest();\r\n    query.setLimit(4);\r\n    query.setName(\"Test address\");\r\n    query.setAddress(\"test address\");\r\n    query.setIsactive(false);\r\n\r\n    const c = new TestClient(\"https://testurl.com\");\r\n    var md = { authorization: \"Bearer \" + JWT };\r\n    c.list(query.serializeBinary(), md, function(err, response) {\r\n      if (err) {\r\n        console.log(\"Error Code:\", err.code);\r\n        console.log(\"Error Message:\", err.message);\r\n      } else {\r\n        console.log(\"Response:\", response);\r\n      }\r\n    });\r\n```\r\nBut as soon as it hits the first 'query.set..' it throws the above error. \r\n\r\nVersions being used are:\r\n \"google-protobuf\": \"^3.6.1\",\r\n \"ts-protoc-gen\": \"^0.7.7-pre.5959599\",\r\n\r\nRunning on the latest version of Google Chrome.\r\n\r\nThanks!\r\n"},"comment":{"url":"https://api.github.com/repos/protocolbuffers/protobuf/issues/comments/424248193","html_url":"https://github.com/protocolbuffers/protobuf/issues/5162#issuecomment-424248193","issue_url":"https://api.github.com/repos/protocolbuffers/protobuf/issues/5162","id":424248193,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNDI0ODE5Mw==","user":{"login":"rnovosad","id":11405694,"node_id":"MDQ6VXNlcjExNDA1Njk0","avatar_url":"https://avatars3.githubusercontent.com/u/11405694?v=4","gravatar_id":"","url":"https://api.github.com/users/rnovosad","html_url":"https://github.com/rnovosad","followers_url":"https://api.github.com/users/rnovosad/followers","following_url":"https://api.github.com/users/rnovosad/following{/other_user}","gists_url":"https://api.github.com/users/rnovosad/gists{/gist_id}","starred_url":"https://api.github.com/users/rnovosad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rnovosad/subscriptions","organizations_url":"https://api.github.com/users/rnovosad/orgs","repos_url":"https://api.github.com/users/rnovosad/repos","events_url":"https://api.github.com/users/rnovosad/events{/privacy}","received_events_url":"https://api.github.com/users/rnovosad/received_events","type":"User","site_admin":false},"created_at":"2018-09-25T08:13:27Z","updated_at":"2018-09-25T08:13:27Z","author_association":"NONE","body":"thanx for the reply\r\nBut this combination `request.setLimit(new Int32Value(args.limit))` doesn't work and throws error\r\n`TS2554: Expected 0 arguments, but got 1.`\r\nSo I wrote a wrapper for it \r\n```const toInt32Value = (value?: number) => {\r\n  const num = new Int32Value()\r\n  if (value) {\r\n    num.setValue(value)\r\n    return num\r\n  }\r\n  return\r\n}"}}
{"actor":{"display_login":"rnovosad"}}