Skip to content

Error running with webpack: ENOENT: no such file or directory, open 'iam_service.json' #1246

@hgardneriv

Description

@hgardneriv

Environment details

  • OS: Linux & MacOS
  • Node.js version: v14.15.0
  • npm version: 6.14.8
  • @google-cloud/pubsub version: 2.10.0

Steps to reproduce

  1. When running a pubsub consumer or producer with webpack, the following error occurs:

"err":{"message":"ENOENT: no such file or directory, open 'iam_service.json'"," stack":"Error: ENOENT: no such file or directory, open 'iam_service.json'\n at Object.openSync (fs.js:476:3)\n at Object.readFileSync (fs.js:377:35)\n at fetch (/Users/harrygardner/Documents/code/cribl/dist/sluice/bin/cribl.bundle.js:403345:34) at Root.load (/Users/harrygardner/Documents/code/cribl/dist/sluice/bin/cribl.bundle.js:403379:13) at Root.loadSync (/Users/harrygardner/Documents/code/cribl/dist/sluice/bin/cribl.bundle.js:403420:17) at Object.loadSync (/Users/harrygardner/Documents/code/cribl/dist/sluice/bin/cribl.bundle.js:105027:29) at GrpcClient.loadFromProto (/Users/harrygardner/Documents/code/cribl/dist/sluice/bin/cribl.bundle.js:245393:48) at GrpcClient.loadProto (/Users/harrygardner/Documents/code/cribl/dist/sluice/bin/cribl.bundle.js:245434:21) at new IamClient (/Users/harrygardner/Documents/code/cribl/dist/sluice/bin/cribl.bundle.js:245684:38) at new SubscriberClient (/Users/harrygardner/Documents/code/cribl/dist/sluice/bin/cribl.bundle.js:86374:26)"

NOTE: This issue only happens when running with webpack, it works expected when webpack is not in use.

  1. This problem can be worked around by creating directory ../../protos and place the following files in it:

$ ls ../../protos
iam_service.json
protos.json

Unfortunately ../../protos falls one level up of our install directory, so it's not a valid work around.

  1. Using the {fallback: true} option in the PubSub constructor, as suggested in this post: Webpack and other bundler support google-cloud-node#2933, results in another error:

`"fetch is not a function","stack":"TypeError: fetch is not a function
at Service.newServiceStub. [as testIamPermissions] (/Users/harrygardner/Documents/code/cribl/dist/sluice/bin/cribl.bundle.js:244522:17)
at /Users/harrygardner/Documents/code/cribl/dist/sluice/bin/cribl.bundle.js:245730:29
at /Users/harrygardner/Documents/code/cribl/dist/sluice/bin/cribl.bundle.js:246661:16
at OngoingCall.call (/Users/harrygardner/Documents/code/cribl/dist/sluice/bin/cribl.bundle.js:244030:27)
at NormalApiCaller.call (/Users/harrygardner/Documents/code/cribl/dist/sluice/bin/cribl.bundle.js:246452:19)
at /Users/harrygardner/Documents/code/cribl/dist/sluice/bin/cribl.bundle.js:244163:30\n at processTicksAndRejections (internal/process/task_queues.js:93:5)

Is there a work around for this issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    api: pubsubIssues related to the googleapis/nodejs-pubsub API.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.web

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions