Skip to content
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

Using buf with serverless application #3490

Closed
YKampani opened this issue Nov 23, 2024 · 3 comments
Closed

Using buf with serverless application #3490

YKampani opened this issue Nov 23, 2024 · 3 comments

Comments

@YKampani
Copy link

GitHub repository with your minimal reproducible example (do not leave this field blank or fill out this field with "github.com/bufbuild/buf" or we will automatically close your issue, see the instructions above!)

No response

What's up?

Hi, I'm using Buf to generate JavaScript files from .proto files, which I package as an npm module. However, when using this in a serverless application, the Lambda deployment fails due to the large package size. The issue seems to stem from needing @bufbuild/buf as a dependency for message encoding/decoding, which increases the size. How can I make this work for a serverless application?

@doriable
Copy link
Member

Hi, please provide more information on this issue:

  • What plugins are you using?
  • What has a dependency on @bufbuild/buf?

As the issue instructions have outlined, you should provide a reproducible example that demonstrates the issue that you're actually running into so we can provide more guidance.

@YKampani
Copy link
Author

So I am trying to generate javascript files from .proto files by running npx buf generate command for my proto folder. Package.json has the below depenencies -

 "dependencies": {
    "@bufbuild/buf": "^1.35.1",
    "@bufbuild/protoc-gen-es": "^1.10.0"
  }

Once the js files are generated i push the folder as npm package in artifactory, on pulling it in consuming lambda application I am able to encode/decode message to/from binary using the generated "_pb.js" files that came from the npm package.
When i tried deploying this code to aws lambda, the deployment failed due to large package deployment size. Lambda allows 50 MB zipped/250 MB unzipped. How can i deploy my lambda in this case? Also do you have an example of how to use buf with serverless, if yes then that would help as well

@doriable
Copy link
Member

It seems that your question has been addressed in our Slack, but just to close the loop on this issue, @paul-sachs has linked an example on cloudflare workers https://github.com/connectrpc/examples-es/tree/main/cloudflare-workers. But generally, this issue seems to be coming from the fact that your package.json is defining @bufbuild/buf as one of your dependencies, but if you are only using it to generate code, it should be defined as a devDependencies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants