feat(napi-derive): add tracing feature for debug logging NAPI function calls#3041
Conversation
How to use the Graphite Merge QueueAdd the label ready-to-merge to this PR to add it to the merge queue. You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. |
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. Comment |
…tion calls Co-authored-by: Brooooooklyn <[email protected]>
|
cursor review |
|
…utput Co-authored-by: Brooooooklyn <[email protected]>
Fixed in 23a25d4. Added |
|
cursor review |
close #7287 refs #7317, napi-rs/napi-rs#3041 With this change, I get the tracing output: ``` $env:RD_LOG="napi=trace"; pnpm build > @example/typescript@ build D:\documents\GitHub\rolldown\examples\basic-typescript > rolldown --config ./rolldown.config.js 2025-12-03T03:05:29.770480Z DEBUG napi: BindingBundler::constructor at crates\rolldown_binding\src\binding_bundler.rs:26 2025-12-03T03:05:29.772016Z DEBUG napi: BindingBundler::write at crates\rolldown_binding\src\binding_bundler.rs:26 2025-12-03T03:05:29.786956Z DEBUG napi: BindingRenderedChunkMeta::chunks at crates\rolldown_binding\src\options\plugin\types\binding_render_chunk_meta_chunks.rs:15 2025-12-03T03:05:29.788489Z DEBUG napi: BindingBundler::close at crates\rolldown_binding\src\binding_bundler.rs:26 2025-12-03T03:05:29.788696Z DEBUG napi: shutdownAsyncRuntime at crates\rolldown_binding\src\lib.rs:79 2025-12-03T03:05:29.788905Z DEBUG napi: BindingOutputChunk::getFileName at crates\rolldown_binding\src\types\binding_output_chunk.rs:17 2025-12-03T03:05:29.789008Z DEBUG napi: BindingOutputChunk::getCode at crates\rolldown_binding\src\types\binding_output_chunk.rs:17 <DIR>/entry.js chunk │ size: 0.23 kB ✔ rolldown v1.0.0-beta.52 Finished in 21.24 ms ``` (note: I had to comment out `debug` option, otherwise I got `failed to set global default subscriber: SetGlobalDefaultError("a global default trace dispatcher has already been set")` error)
tracingfeature tonapi-derivecrate's Cargo.tomltracingfeature tonapi-derive-backendcratetracingfeature tonapi-derive-backendcrate's Cargo.tomltracingfeature tonapicrate's Cargo.toml and re-export frombindgen_preludefn.rsto emittracing::debug!logs with function names when the feature is enabledstruct.rs(getters, setters, constructor)parent_js_namefield toNapiFn)Security Summary
The changes were manually reviewed and no security vulnerabilities were found. The implementation:
tracingcrateOriginal prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.
Note
Adds an opt-in
tracingfeature that emits debug logs for NAPI function/class call entry points and wires the feature across crates.tracing::debug!at NAPI function entry points and error-thunk wrappers; includes class context viaparent_js_name.NapiFn.parent_js_nameand plumb it from parser for accurate JS names.tracingfeature tonapi-derive-backend,napi-derive, andnapicrates; guarded code paths when disabled.napire-exportstracingfrombindgen_preludeand adds optionaltracingdependency.Written by Cursor Bugbot for commit 23a25d4. This will update automatically on new commits. Configure here.