refactor(linter/plugins): add debug assert for passing data from NAPI callback#16465
Merged
graphite-app[bot] merged 1 commit intomainfrom Dec 3, 2025
Conversation
This was referenced Dec 3, 2025
Member
Author
camc314
approved these changes
Dec 3, 2025
Member
Author
|
@camc314 I actually think Broooklyn was right all along (surprise!). So IMO this solution is better. |
Contributor
makes sense to me! |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors error handling in NAPI callback wrappers by replacing ignored tx.send() results with explicit debug assertions. The change adds documentation explaining why these calls cannot fail and validates the assumption with debug_assert! in debug builds, while maintaining zero overhead in release builds for these performance-critical JS-to-Rust boundaries.
- Replaces
let _ = tx.send(result)with explicit result handling and debug assertions - Adds detailed comments explaining the impossibility of
tx.send()failures - Applies the same pattern to both
setupConfigsandlintFilecallback wrappers
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Member
Author
Merge activity
|
… callback (#16465) Alternative to #16463. I think I've understood the situation now, and why Brooooklyn's original code ignored the result of `tx.send()`. It is genuinely impossible for the call to `tx.send()` to fail, and that doesn't depend on there not being a bug in NAPI-RS - it's provable just from looking at the code in these functions, regardless of what NAPI-RS may do. Add comments explaining why we can safely ignore the result of `tx.send()`, and add a `debug_assert!` just to make sure. We want to absolutely minimize the overhead of moving between JS and Rust, so I think it's appropriate to leave out error handling for impossible cases like these.
3544a69 to
467cc1a
Compare
d6b2ae6 to
f9c883e
Compare
Base automatically changed from
12-03-docs_linter_plugins_improve_comment_on_error_branch
to
main
December 3, 2025 19:20
taearls
pushed a commit
to taearls/oxc
that referenced
this pull request
Dec 11, 2025
… callback (oxc-project#16465) Alternative to oxc-project#16463. I think I've understood the situation now, and why Brooooklyn's original code ignored the result of `tx.send()`. It is genuinely impossible for the call to `tx.send()` to fail, and that doesn't depend on there not being a bug in NAPI-RS - it's provable just from looking at the code in these functions, regardless of what NAPI-RS may do. Add comments explaining why we can safely ignore the result of `tx.send()`, and add a `debug_assert!` just to make sure. We want to absolutely minimize the overhead of moving between JS and Rust, so I think it's appropriate to leave out error handling for impossible cases like these.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Alternative to #16463.
I think I've understood the situation now, and why Brooooklyn's original code ignored the result of
tx.send().It is genuinely impossible for the call to
tx.send()to fail, and that doesn't depend on there not being a bug in NAPI-RS - it's provable just from looking at the code in these functions, regardless of what NAPI-RS may do.Add comments explaining why we can safely ignore the result of
tx.send(), and add adebug_assert!just to make sure.We want to absolutely minimize the overhead of moving between JS and Rust, so I think it's appropriate to leave out error handling for impossible cases like these.