-
Notifications
You must be signed in to change notification settings - Fork 257
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
fix(js): replace deno_core
with rquickjs
#1713
Conversation
WalkthroughWalkthroughThe changes primarily involve transitioning from Changes
Assessment against linked issues
Possibly related issues
Recent Review DetailsConfiguration used: CodeRabbit UI Files selected for processing (1)
Additional Context UsedPath-based Instructions (1)
Additional comments not posted (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1713 +/- ##
==========================================
- Coverage 89.61% 89.55% -0.06%
==========================================
Files 151 151
Lines 15547 15841 +294
==========================================
+ Hits 13932 14186 +254
- Misses 1615 1655 +40 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
#[rquickjs::function] | ||
fn qjs_print(msg: String, is_err: bool) { | ||
if is_err { | ||
tracing::error!("{msg}"); | ||
} else { | ||
tracing::info!("{msg}"); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactor qjs_print
to handle potential errors in a more robust way.
Currently, qjs_print
uses unconditional printing based on the is_err
flag. Consider enhancing error handling by integrating with the logging framework or providing a mechanism to handle or report errors when printing fails.
fn qjs_print(msg: String, is_err: bool) {
if is_err {
- eprintln!("{msg}")
+ if let Err(e) = eprintln!("{msg}") {
+ log::error!("Failed to print error message: {}", e);
+ }
} else {
- println!("{msg}")
+ if let Err(e) = println!("{msg}") {
+ log::error!("Failed to print message: {}", e);
+ }
}
}
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
#[rquickjs::function] | |
fn qjs_print(msg: String, is_err: bool) { | |
if is_err { | |
tracing::error!("{msg}"); | |
} else { | |
tracing::info!("{msg}"); | |
} | |
} | |
#[rquickjs::function] | |
fn qjs_print(msg: String, is_err: bool) { | |
if is_err { | |
if let Err(e) = eprintln!("{msg}") { | |
log::error!("Failed to print error message: {}", e); | |
} | |
} else { | |
if let Err(e) = println!("{msg}") { | |
log::error!("Failed to print message: {}", e); | |
} | |
} | |
} |
Action required: PR inactive for 2 days. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for some reason these changes not compiling for me when using rust v1.75.0. And with v1.77 it's fine
Action required: PR inactive for 2 days. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Out of diff range and nitpick comments (8)
examples/scripts/echo.js (1)
1-8
: LGTM! Consider adding a comment explaining why a newRequest
object is created instead of modifying the existing one.src/cli/javascript/runtime.rs (2)
52-60
: The implementation of theLocalRuntime
struct and its methods are robust and correctly handle the initialization of the new JS runtime. Consider adding more detailed logging within thetry_new
method to aid in debugging.
102-128
: Utility functions such asprepare_args
andcall
are correctly implemented with consistent error handling. Consider standardizing the format of error messages for consistency across the codebase.src/cli/javascript/request_filter.rs (1)
98-154
: The new tests for theFromJs
implementation are comprehensive and well-structured. Consider adding comments to each test case to explain the specific scenario being tested.src/cli/javascript/js_response.rs (2)
10-27
: The modifications to theJsResponse
struct for QuickJS integration are correctly implemented. Consider adding detailed documentation for the QuickJS methods to aid in understanding their usage.
135-179
: > 📝 NOTEThis review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [65-178]
The tests for converting
JsResponse
to and from JavaScript objects are comprehensive and effectively cover various scenarios. Consider using more descriptive names for the tests to clarify their purpose.src/cli/javascript/js_request.rs (2)
8-48
: The modifications to theJsRequest
andUri
structs for QuickJS integration are correctly implemented. Consider adding detailed documentation for the QuickJS methods to aid in understanding their usage.
188-253
: > 📝 NOTEThis review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [142-252]
The tests for converting
JsRequest
andUri
to and from JavaScript objects are comprehensive and effectively cover various scenarios. Consider using more descriptive names for the tests to clarify their purpose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Action required: PR inactive for 2 days. |
Action required: PR inactive for 2 days. |
83a8055
to
42bccb4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
83a8055
to
b895ff9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 17
8914c32
to
be31865
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Out of diff range and nitpick comments (1)
src/cli/javascript/js_request.rs (1)
44-59
: The conversion implementations forJsRequest
are correct. Consider reviewing the performance impact of cloning in theTryFrom
implementation, especially for large requests.
deno_core
with rquickjs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Out of diff range and nitpick comments (1)
src/cli/javascript/js_request.rs (1)
Line range hint
134-207
: TheIntoJs
andFromJs
implementations forScheme
andUri
handle conversions well. Consider improving the clarity of error messages.- message: Some("unable to cast JS Value as object".to_string()), + message: Some("Expected JS Value to be an object but got another type".to_string()),
Summary:
Replaces V8 with QuickJS as the JS runtime
Issue Reference(s):
Fixes #1690
/claim 1690
Build & Testing:
cargo test
successfully../lint.sh --mode=fix
to fix all linting issues raised by./lint.sh --mode=check
.Checklist:
<type>(<optional scope>): <title>
Size Comparison
After
Before
Summary by CodeRabbit
New Features
rquickjs
for enhanced JavaScript runtime handling in Rust CLI applications, replacingdeno_core
.JsRequest
,JsResponse
, andCommand
types to and from JavaScript values.console
object to improve logging functionality.Bug Fixes
handle.rs
for more accurate file path handling.Refactor
rquickjs
for JavaScript integration, affecting various components like requests, responses, and runtime management.Tests
Documentation