Skip to content
This repository has been archived by the owner on Apr 8, 2024. It is now read-only.

Unable to use library with external builds - zeebe.proto file path passed to proto.path #299

Closed
BaluVyamajala opened this issue Feb 8, 2023 · 5 comments

Comments

@BaluVyamajala
Copy link

BaluVyamajala commented Feb 8, 2023

When library is used in applications which uses external builds , direct references to files example: https://github.com/camunda-community-hub/zeebe-client-node-js/blob/master/src/zb/ZBClient.ts#L1292 throwing errors.

Current Behavior

Error: ENOENT: no such file or directory, open '/Users/myUser/proto/zeebe.proto'
    at Object.openSync (node:fs:600:3)
    at Object.readFileSync (node:fs:468:35)
    at fetch (/Users/myUser/camunda-zrpc-test/dist/out.js:31582:30)
    at Root.load (/Users/myUser/camunda-zrpc-test/dist/out.js:31611:11)
    at Root.loadSync (/Users/myUser/camunda-zrpc-test/dist/out.js:31621:19)
    at loadProtosWithOptionsSync (/Users/myUser/camunda-zrpc-test/dist/out.js:35023:31)
    at loadSync (/Users/myUser/camunda-zrpc-test/dist/out.js:36043:63)
    at new GrpcClient (/Users/myUser/camunda-zrpc-test/dist/out.js:44115:62)
    at GrpcMiddleware.createInterceptedGrpcClient (/Users/myUser/camunda-zrpc-test/dist/out.js:44455:28)
    at new GrpcMiddleware (/Users/myUser/camunda-zrpc-test/dist/out.js:44452:32) {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '/Users/myUser/proto/zeebe.proto'
}

Possible solutions

Rather than directly referencing a path to a file. we could use require/import the file and use it.

Steps to Reproduce

Sample Repo https://github.com/BaluVyamajala/camunda-zrpc-esbuild-test

npm run build
node dist/out.js 
@jwulf
Copy link
Member

jwulf commented Feb 8, 2023

Just out of curiosity, what's the motivation for using ESBuild on Node?

@BaluVyamajala
Copy link
Author

Just out of curiosity, what's the motivation for using ESBuild on Node?

Currently we are building a lambda function in AWS and to make these efficient, we build a minified file making it super small and without including entire node_modules folder. For example https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda_nodejs-readme.html library uses esbuild behind the scenes.

@jwulf
Copy link
Member

jwulf commented Feb 13, 2023

OK. I've done this before. From memory: you need to add a build step to move the proto file. Since it is dynamically loaded and is not a .js asset, the builder needs to be made aware of it.

@jwulf
Copy link
Member

jwulf commented Feb 13, 2023

@jwulf
Copy link
Member

jwulf commented Mar 28, 2023

I'm going to close this for now. If you figure out a way to do this, let me know.

@jwulf jwulf closed this as completed Mar 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants