Skip to content

fix(wasm): reqwest build error#2661

Merged
xusd320 merged 1 commit intonextfrom
fix-wasm-build
Mar 4, 2026
Merged

fix(wasm): reqwest build error#2661
xusd320 merged 1 commit intonextfrom
fix-wasm-build

Conversation

@elrrrrrrr
Copy link
Contributor

  • 🐞 fix reqwest build error in wasm
  • ♻️ update utoo-web CI flow

@elrrrrrrr elrrrrrrr requested a review from xusd320 March 4, 2026 12:06
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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!

This pull request addresses critical WebAssembly build issues by adjusting how reqwest errors are classified for WASM targets and incorporating a necessary random number generator dependency. It also streamlines the project's build process by updating package.json scripts to directly manage NAPI builds and compilation steps, ensuring a more robust and efficient CI workflow for utoo-web.

Highlights

  • WASM Build Fix: Resolved a build error for WebAssembly targets by conditionally handling reqwest connection errors and introducing the getrandom dependency with the js feature.
  • CI Flow Update: The utoo-web CI flow has been updated, specifically by refactoring package.json build scripts to directly integrate napi build commands and streamline the CJS/ESM compilation process.
  • Dependency Management: The Cargo.lock and crates/utoo-wasm/Cargo.toml files were updated to include the getrandom crate, essential for WASM compatibility.
  • WASM Bindings Refinement: The index.d.ts file for utoo-web saw a reordering and update of wasm-bindgen generated function declarations, reflecting underlying changes in the WASM module.
Changelog
  • Cargo.lock
    • Added getrandom 0.2.16 to the dependency lock file.
  • crates/ruborist/src/service/manifest.rs
    • Modified the classify_reqwest_error function to exclude is_connect() from retryable errors when compiling for wasm32 targets.
  • crates/utoo-wasm/Cargo.toml
    • Added the getrandom dependency with the js feature enabled for WebAssembly builds.
  • packages/pack/package.json
    • Refactored the build, build:js, build:local, and prepublishOnly scripts to directly invoke napi build and integrate CJS/ESM compilation steps, removing intermediate npm run calls.
    • Reordered build steps within the scripts for better clarity and efficiency.
  • packages/utoo-web/src/utoo/index.d.ts
    • Reordered and updated wasm-bindgen generated function declarations within the InitOutput interface, reflecting changes in the WASM module's exports.
Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/utooweb-ci.yml
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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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

  1. 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.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request fixes a reqwest build error for the wasm target by conditionally compiling the is_connect() check. No security vulnerabilities were found. However, the build scripts in packages/pack/package.json have become very long and contain significant duplication; it is suggested to refactor them to improve readability and maintainability by reintroducing composable npm scripts.

I am having trouble creating individual review comments. Click here to see my feedback.

packages/pack/package.json (74-85)

medium

The build scripts (build, build:js, build:local, prepublishOnly) have been expanded, leading to significant code duplication. For instance, the logic for building CJS and ESM modules is repeated in multiple scripts. This makes the scripts harder to read and maintain.

To improve this, I suggest reverting to a more modular approach using npm run to compose smaller, reusable scripts. This will make the scripts section cleaner and easier to manage.

    "build": "npm run build:binding && npm run build:js",
    "build:js": "npm run build:cjs && npm run build:esm",
    "build:cjs": "rm -rf cjs && tsc -p ./tsconfig.json --module commonjs --outDir cjs && cp src/*.d.ts cjs/",
    "build:esm": "rm -rf esm && tsc -p ./tsconfig.json --module esnext --outDir esm && cp src/*.d.ts esm/ && node ../../scripts/add-esm-extensions.cjs && node scripts/inject-esm-dirname.cjs",
    "build:local": "npm run build:binding:local && turbo run build --filter=@utoo/pack-shared && npm run build:js && cp src/*.node cjs/ && cp src/*.node esm/",
    "artifacts": "napi artifacts --dir ./src --dist npm",
    "build:binding": "napi build src --platform --release -p pack-napi --cargo-cwd ../../ --cargo-name pack_napi --features plugin --js binding.js --dts binding.d.ts",
    "build:binding:local": "napi build src --platform --profile release-local -p pack-napi --cargo-cwd ../../ --cargo-name pack_napi --features plugin --js binding.js --dts binding.d.ts",
    "clean": "rm -rf cjs esm",
    "prepublishOnly": "npm run build:js && napi prepublish -t npm --skip-gh-release",
    "version": "napi version",
    "generate-features-list": "node ./scripts/generate-feature-list.js"

@xusd320 xusd320 enabled auto-merge (squash) March 4, 2026 12:10
@xusd320 xusd320 disabled auto-merge March 4, 2026 12:10
@xusd320 xusd320 enabled auto-merge (squash) March 4, 2026 12:10
@xusd320 xusd320 merged commit 4044acc into next Mar 4, 2026
16 checks passed
@xusd320 xusd320 deleted the fix-wasm-build branch March 4, 2026 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants