webpack on the browser "cannot read property 'status' of undefined"
See original GitHub issueReferences:
http://5.9.10.113/67017244/google-cloud-pubsub-typeerror-cannot-read-property-status-of-undefined https://github.com/googleapis/nodejs-pubsub/issues/1011 https://github.com/googleapis/gax-nodejs/pull/554
// pull-retry.js
const google_gax_1 = require("google-gax");
/*!
* retryable grpc.status codes
*/
exports.RETRY_CODES = [
google_gax_1.grpc.status.DEADLINE_EXCEEDED,
google_gax_1.grpc.status.RESOURCE_EXHAUSTED,
google_gax_1.grpc.status.ABORTED,
google_gax_1.grpc.status.INTERNAL,
google_gax_1.grpc.status.UNAVAILABLE,
google_gax_1.grpc.status.CANCELLED,
];
I understand that there isn’t supposed to be support for webpack, but it seems like it shouldn’t be that bad to hack a few libraries into working. I’ve tried the following just to hack past the errors that I’ve seen in browser:
// @google-cloud/pubsub/build/src/pull-retry.js : 20
const google_gax_1 = require("google-gax");
<NEW>
google_gax_1.grpc = {"status": {}};
</NEW>
The above fixes the original error, but then I get another error that I fix below
// google-auth-library/build/src/auth/googleauth.js : 415
resolve("my-project-id");
// child_process_1.exec('gcloud config config-helper --format json', (err, stdout) => {
// if (!err && stdout) {
// try {
// const projectId = JSON.parse(stdout).configuration.properties.core.project;
// resolve(projectId);
// return;
// }
// catch (e) {
// // ignore errors
// }
// }
// resolve(null);
// });
I’m currently stuck at @google-cloud/pubsub/build/src/v1/publisher_client.js : 110
const google_gax_1 = require("google-gax");
...
this.iamClient = new google_gax_1.IamClient(this._gaxGrpc, opts);
google_gax_1.IamClient is undefined for some reason and it therefore says that google_gax_1.IamClient is not a constructor.
I this path of hacking through libraries likely to work for me in the end or am I doomed?
Issue Analytics
- State:
- Created 2 years ago
- Comments:10
Top GitHub Comments
Also, for reference my code is almost identical to the example code for Publishing to a topic in Node.
https://cloud.google.com/pubsub/docs/publisher
The only difference being that I authenticate explicitly.
The latest feedback I’ve gotten re: using the library in a browser context is that we really don’t support that at this point, but it’s something that we’re periodically revisiting.