-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
Which project does this relate to?
Start
Describe the bug
The pub-sub-api-node-client library (intended for backend/server only) works fine in development, but fails at runtime when bundled with nitro for docker deployment.
The author of the library suggested that it might be because of the bundling process:
Main issues are the library's cert file not being found, and fs being null (but only in the context of the @grpc/grpc-js's proto-loader package).
Your Example Website or App
https://github.com/nktnet-bug-report/sf-pubsub-api-test
Steps to Reproduce the Bug or Issue
Same instructions as listed in the README.md of the minimal reproducible example:
click to view
Setup
pnpm install
cp .env.example .envSet up env as per ./.env.example
Development
pnpm devClick on the green "Salesforce Pubsub Test" button or go to http://localhost:3000/sf-pubsub
Observe that there are no errors.
Production
Install the dotenv CLI tool is install to read from .env.
Bug 1 - no such file (cert)
Error: ENOENT: no such file or directory, open '/path/.output/server/_libs/cacert-2ebcb9e8.pem'
pnpm build && dotenv -f .env run node .output/server/index.mjsBug 2 - fs is null
TypeError: Cannot read properties of null (reading 'readFileSync')
pnpm build && cp ./node_modules/salesforce-pubsub-api-client/dist/*.pem .output/server/_libs/ && dotenv -f .env run node .output/server/index.mjsExpected behavior
It should work in production without runtime errors, just like in development.
Platform
- Router / Start Version: [e.g. 1.132.0]
- OS: macOS, Linux
- Browser: Zen
- Browser Version: 1.17.15b
- Bundler: vite
- Bundler Version: 7.1.7
Additional context
Original issue:
When using Next.JS, the library works fine (with a small hiccup where I needed to use turbopackMinify: false).
Also cross-posted here (not sure if it's a nitro issue or tanstack start issue):