Repository navigation
docs(profiler): document V8 native pprof addon requirement on Bun - #9727
danieljbruce wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the documentation in .readme-partials.yaml and README.md to clarify Node.js version support and explicitly note that @google-cloud/profiler is incompatible with the Bun runtime due to its dependency on V8 C++ APIs. Feedback on these changes suggests simplifying the Node.js version requirement phrasing to refer generally to supported V8-based LTS releases (Node.js 14 or higher). Additionally, the reviewer warns that manual edits to README.md may be overwritten during template regeneration and recommends applying these updates upstream.
| ### Prerequisites | ||
|
|
||
| 1. Your application will need to be using Node.js version between 14 and 20. | ||
| 1. Your application will need to be using Node.js version between 14 and 20 (or a supported V8-based Node.js LTS release). |
There was a problem hiding this comment.
The phrasing "Node.js version between 14 and 20 (or a supported V8-based Node.js LTS release)" is redundant and slightly confusing. Since Node.js 22 is now an LTS release and is supported, we can simplify this to refer generally to supported V8-based Node.js LTS releases (Node.js 14 or higher).
1. Your application will need to be using a supported V8-based Node.js LTS release (Node.js 14 or higher).| For example, `npm install @google-cloud/profiler@legacy-8` installs client libraries | ||
| for versions compatible with Node.js 8. | ||
|
|
||
| > **Note on Bun and Non-V8 Runtimes:** `@google-cloud/profiler` depends on [`pprof`](https://www.npmjs.com/package/pprof), a native C++ addon compiled against V8's `v8::CpuProfiler` and `v8::HeapProfiler` C++ APIs (`v8-profiler.h`). Because Bun uses JavaScriptCore (JSC) instead of V8, `@google-cloud/profiler` is **not supported on the Bun runtime**. For Bun applications on Google Cloud, use OpenTelemetry (`@google-cloud/opentelemetry-cloud-trace-exporter` and `@google-cloud/opentelemetry-cloud-monitoring-exporter`) for observability. |
There was a problem hiding this comment.
Since README.md is typically generated from templates and .readme-partials.yaml, any manual edits made directly to README.md (such as this note) may be overwritten during the next regeneration. Please ensure this note is either added via a supported partial in .readme-partials.yaml or that the generation process is updated to preserve it.
References
- Do not manually edit auto-generated files to fix typos or make other changes, as these edits will be overwritten during the next regeneration. Instead, apply the fixes upstream in the generator or templates.
| ### Prerequisites | ||
|
|
||
| 1. Your application will need to be using Node.js version between 14 and 20. | ||
| 1. Your application will need to be using Node.js version between 14 and 20 (or a supported V8-based Node.js LTS release). |
There was a problem hiding this comment.
[Generated] Document the V8 C++ CPU & Heap Profiler (v8::CpuProfiler, v8::HeapProfiler) requirement of the pprof native addon in .readme-partials.yaml so automated README generation preserves the Bun (JavaScriptCore) runtime compatibility notice.
| [`pprof`](https://www.npmjs.com/package/pprof) module, a module with a native C++ | ||
| component (`pprof.node`) compiled against V8's `v8::CpuProfiler` and `v8::HeapProfiler` | ||
| C++ APIs (`v8-profiler.h`). | ||
| * **Bun / JavaScriptCore Incompatibility:** Because Bun uses JavaScriptCore (JSC) instead of V8 and does not expose V8's C++ profiling ABI, `@google-cloud/profiler` is **not supported on the Bun runtime**. For Bun workloads on Google Cloud, use OpenTelemetry (`@google-cloud/opentelemetry-cloud-trace-exporter` and `@google-cloud/opentelemetry-cloud-monitoring-exporter`) instead. |
There was a problem hiding this comment.
[Generated] Document the V8 C++ CPU & Heap Profiler (v8::CpuProfiler, v8::HeapProfiler) requirement of the pprof native addon in .readme-partials.yaml so automated README generation preserves the Bun (JavaScriptCore) runtime compatibility notice.
| for versions compatible with Node.js 8. | ||
|
|
||
| > **Note on Bun and Non-V8 Runtimes:** `@google-cloud/profiler` depends on [`pprof`](https://www.npmjs.com/package/pprof), a native C++ addon compiled against V8's `v8::CpuProfiler` and `v8::HeapProfiler` C++ APIs (`v8-profiler.h`). Because Bun uses JavaScriptCore (JSC) instead of V8, `@google-cloud/profiler` is **not supported on the Bun runtime**. For Bun applications on Google Cloud, use OpenTelemetry (`@google-cloud/opentelemetry-cloud-trace-exporter` and `@google-cloud/opentelemetry-cloud-monitoring-exporter`) for observability. | ||
|
|
There was a problem hiding this comment.
[Generated] Add a Runtime Compatibility (Node.js vs. Bun) section to @google-cloud/profiler README.md explaining why pprof requires Node.js V8 C++ profiler APIs and providing a safe typeof Bun === "undefined" dynamic import guard for multi-runtime services.
0782bd2 to
3c00882
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request updates the documentation in README.md and .readme-partials.yaml to clarify Node.js version requirements and explicitly document that @google-cloud/profiler is incompatible with the Bun runtime due to its dependency on V8 C++ APIs. Feedback on the changes suggests simplifying the Node.js version phrasing in .readme-partials.yaml to avoid contradiction and clearly state support for any V8-based Node.js LTS release of version 14 or higher.
| ### Prerequisites | ||
|
|
||
| 1. Your application will need to be using Node.js version between 14 and 20. | ||
| 1. Your application will need to be using Node.js version between 14 and 20 (or a supported V8-based Node.js LTS release). |
There was a problem hiding this comment.
The phrasing "Node.js version between 14 and 20 (or a supported V8-based Node.js LTS release)" is slightly contradictory and confusing, as it first restricts the version to 14-20 and then immediately expands it to other LTS releases (like Node 22). We should simplify this to clearly state that any supported V8-based Node.js LTS release (version 14 or higher) is required.
1. Your application will need to be using a supported V8-based Node.js LTS release (Node.js 14 or higher).| ### Prerequisites | ||
|
|
||
| 1. Your application will need to be using Node.js version between 14 and 20. | ||
| 1. Your application will need to be using Node.js version between 14 and 20 (or a supported V8-based Node.js LTS release). |
There was a problem hiding this comment.
Nit: should we update this sentence to include the Node ranges we support?
| For example, `npm install @google-cloud/profiler@legacy-8` installs client libraries | ||
| for versions compatible with Node.js 8. | ||
|
|
||
| > **Note on Bun and Non-V8 Runtimes:** `@google-cloud/profiler` depends on [`pprof`](https://www.npmjs.com/package/pprof), a native C++ addon compiled against V8's `v8::CpuProfiler` and `v8::HeapProfiler` C++ APIs (`v8-profiler.h`). Because Bun uses JavaScriptCore (JSC) instead of V8, `@google-cloud/profiler` is **not supported on the Bun runtime**. For Bun applications on Google Cloud, use OpenTelemetry (`@google-cloud/opentelemetry-cloud-trace-exporter` and `@google-cloud/opentelemetry-cloud-monitoring-exporter`) for observability. |
There was a problem hiding this comment.
Nit: This note seems quite specific, and I feel like it implies that we want to support runtimes other than Node, which isn't the case for this profiler.
Description
Documents @google-cloud/profiler V8 native pprof addon requirement and Bun incompatibility.
Impact
Clarifies why @google-cloud/profiler requires V8 Node.js and cannot run on Bun.
Changes
handwritten/cloud-profiler/.readme-partials.yamlandhandwritten/cloud-profiler/README.mdto explicitly document that@google-cloud/profilerdepends on the native C++pprofaddon compiled against V8'sv8::CpuProfilerandv8::HeapProfilerC++ APIs (v8-profiler.h).@google-cloud/profiler, and advise Bun users to use--ignore-scriptsor omit@google-cloud/profilerin Bun deployments while using OpenTelemetry (@google-cloud/opentelemetry-cloud-trace-exporter/ Cloud Monitoring) for observability.Testing
python3 .agents/skills/cistack/scripts/cistack.py --repo-root . --base-ref fix/b578003818-gax-stream-cancel-abort --branches docs/b578005545-profiler-bun-v8-addon --mode preflight-push2andbun --bun bin/run-test.cjs --no-c8 core/packages/gax/build/test/unit/streamArrayParser.js.node ./bin/linter.mjs --strictinhandwritten/cloud-profiler.handwritten/cloud-profilerunit tests pass under Node.js.Alternatives
handwritten/cloud-profiler/src/index.tsbefore importingpprof; rejected as a standalone fix because top-levelimport {heap as heapProfiler} from 'pprof'andbun installnativenode-gyp rebuildhooks already fail before user code callsprofiler.start().pprofC++ bindings to JavaScriptCore; infeasible because JSC does not expose V8'sv8-profiler.hC++ ABI (v8::CpuProfiler/v8::HeapProfiler).node-gypbuild or native addon load errors.Fixes b/578005545
For b/564576254