fix(wasm): utoopack unreachable and add tracing log#2124
Conversation
There was a problem hiding this comment.
Summary of Changes
Hello @xusd320, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
The pull request addresses a critical deserialization panic in the pack configuration for WASM builds and significantly improves the tracing capabilities within the WASM module. It also updates dependencies and refactors the build process execution.
Highlights
- WASM Configuration Refinement: The
packconfiguration handling in the WASM module has been enhanced to prevent deserialization panics. It now gracefully defaults to a production mode configuration if none is provided and correctly merges user-supplied configurations, ensuring robustness. The configuration file name has also been standardized fromproject_options.jsontoutoopack.json. - Enhanced Tracing and Logging: Tracing within the WASM module has been improved by updating the default tracing targets, enabling the logging of span close events, and setting the
utoo_wasmmodule's log level toinfofor better visibility into the build process. - Build Process Execution Change: The asynchronous build task execution in the WASM environment has been switched from
tokio::runtime::Runtime::spawntotokio::runtime::Runtime::block_on, which might simplify the runtime management or address specific WASM threading/scheduling considerations. - Dependency and Workspace Updates: Key dependencies like
opfs-projectandtokio-fs-exthave been updated, and thetokiocrate now includes thertfeature, indicating a more specific runtime requirement. Workspace dependency management for some crates has also been adjusted. - Demo Application Alignment: The
utooweb-demoexample has been updated to align with the newutoopack.jsonconfiguration file, improve the visual sorting of files in the tree view, enhance error reporting, and make minor UI adjustments for a better user experience.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Code Review
This pull request introduces fixes for deserialization panics in the wasm pack configuration and enhances tracing logs for better debugging. The changes involve updating dependencies, refining the build process, and improving error handling. My review focuses on further improving code clarity and debuggability. I've suggested making an error message more descriptive and simplifying the construction of the tracing filter string for better maintainability.
| let mut trace = TRACING_OVERVIEW_TARGETS | ||
| .iter() | ||
| // .filter(|_| true) | ||
| .cloned() | ||
| .collect::<Vec<&str>>(); | ||
| trace.push("utoo_wasm"); | ||
| trace.extend(["utoo_wasm=info"]); | ||
| trace.join(",") |
There was a problem hiding this comment.
This block of code for building the filter string can be simplified for better readability and conciseness. Instead of creating a mutable vector and extending it, you can directly join the existing targets and append the new one.
| let mut trace = TRACING_OVERVIEW_TARGETS | |
| .iter() | |
| // .filter(|_| true) | |
| .cloned() | |
| .collect::<Vec<&str>>(); | |
| trace.push("utoo_wasm"); | |
| trace.extend(["utoo_wasm=info"]); | |
| trace.join(",") | |
| let mut filter = TRACING_OVERVIEW_TARGETS.join(","); | |
| filter.push_str(",utoo_wasm=info"); | |
| filter |
| std::result::Result::<RcStr, JsValue>::Ok(format!(r#"{{ "mode": {mode}}}"#).into()), | ||
| |config| { | ||
| let mut val = serde_json::value::Value::from_str(&config) | ||
| .map_err(|e| JsValue::from_str("Failed to parse pack config"))?; |
There was a problem hiding this comment.
The current error message Failed to parse pack config is not very descriptive and could make debugging difficult. It would be more helpful to include the underlying error from serde_json to provide more context on why the parsing failed.
| .map_err(|e| JsValue::from_str("Failed to parse pack config"))?; | |
| .map_err(|e| JsValue::from_str(&format!("Failed to parse pack config: {e}")))?; |
Summary
Test Plan