Skip to content

Conversation

Wan9xy
Copy link

@Wan9xy Wan9xy commented Mar 5, 2025

Add HTTP3 support to feature flags

Description

Currently, the feature flags do not include HTTP3 support, which creates a limitation for users who need to enable the HTTP3 feature in the reqwest library. Without this addition, users who try to enable HTTP3 face challenges:

  1. They cannot re-import reqwest with different features, as this causes Rust to panic
  2. HTTP3 functionality remains inaccessible despite being needed for certain use cases

This PR adds HTTP3 to the allowed feature flags, enabling users to leverage this experimental functionality in Rust-side code.

Changes Made

  • Added HTTP3 to the list of permitted feature flags
  • Limited this feature to Rust-side usage only, as HTTP3 is still experimental
  • Ensured compatibility with existing feature flag implementations

Notes

  • HTTP3 is considered experimental in reqwest, so this feature should be used with caution
  • This change only affects Rust-side code and doesn't impact other parts of the system

Testing

  • Verified that enabling the HTTP3 feature flag works correctly
  • Ensured that existing functionality remains unaffected

@Wan9xy Wan9xy requested a review from a team as a code owner March 5, 2025 02:42
Copy link
Member

@amrbashir amrbashir left a comment

Choose a reason for hiding this comment

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

Thank you could you add a change file in .changes directory?

@Wan9xy
Copy link
Author

Wan9xy commented Mar 5, 2025

@amrbashir Sure, i added add-http3-feature-flag.md to .change dict

Copy link
Member

@amrbashir amrbashir left a comment

Choose a reason for hiding this comment

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

Thank you

Copy link
Contributor

github-actions bot commented Mar 5, 2025

Package Changes Through 23c1a36

There are 4 changes which include http with patch, http-js with patch, log with minor, log-js with minor

Planned Package Versions

The following package releases are the planned based on the context of changes in this pull request.

package current next
api-example 2.0.19 2.0.20
api-example-js 2.0.15 2.0.16
http 2.3.0 2.3.1
http-js 2.3.0 2.3.1
log 2.2.3 2.3.0
log-js 2.2.3 2.3.0

Add another change file through the GitHub UI by following this link.


Read about change files or the docs at github.com/jbolda/covector

@amrbashir
Copy link
Member

As this requires passing specific flag to rustc, I am hesitant to merge this, especially since the following works.

tauri-plugin-http = "2"
reqwest = { version = "0.12", features = ["http3"] }

@amrbashir
Copy link
Member

also seeing #2491, it seems to be a rust compiler panic that is not related to the feature.

@Wan9xy
Copy link
Author

Wan9xy commented Mar 5, 2025

As this requires passing specific flag to rustc, I am hesitant to merge this, especially since the following works.

tauri-plugin-http = "2"
reqwest = { version = "0.12", features = ["http3"] }

When I use reqwest 0.11 and enabled http3 feature, it will not panic, but when the version > 0.12 and enable the feature, rs will get a panic. i have no idea why does it happen,.
This error cause me can not use http plugin, and rewrite my code all in rust, the work is too heavy for most times.
Only require reqwest and http3 worked well now, but I also want to use the plugin make my work easier. HHH

@amrbashir
Copy link
Member

Can you make a repro I can test with?

@Wan9xy
Copy link
Author

Wan9xy commented Mar 6, 2025

Can you make a repro I can test with?

Sure, just follow next steps

  • create a new project
D:\src>cargo create-tauri-app
✔ Project name · http3-test
✔ Identifier · com.http3-test.app
✔ Choose which language to use for your frontend · TypeScript / JavaScript - (pnpm, yarn, npm, deno, bun)
✔ Choose your package manager · yarn
✔ Choose your UI template · React - (https://react.dev/)
✔ Choose your UI flavor · TypeScript

Template created! To get started run:
  cd http3-test
  yarn
  yarn tauri android init

For Desktop development, run:
  yarn tauri dev

For Android development, run:
  yarn tauri android dev
  • add http-plugin
PS D:\src\http3-test> cargo tauri add http
    Info Installing Cargo dependency "tauri-plugin-http"...
    Updating crates.io index
      Adding tauri-plugin-http v2 to dependencies                                                                                                                                                                                                                                                             
             Features as of v2.0.0:
             + charset
             + cookies
             + http2
             + macos-system-configuration
             + rustls-tls
             - blocking
             - brotli
             - deflate
             - gzip
             - json
             - multipart
             - native-tls
             - native-tls-alpn
             - native-tls-vendored
             - rustls-tls-manual-roots
             - rustls-tls-native-roots
             - rustls-tls-webpki-roots
             - socks
             - stream
             - trust-dns
             - unsafe-headers
    Updating crates.io index
     Locking 14 packages to latest compatible versions                                                                                                                                                                                                                                                        
      Adding atomic-waker v1.1.2
      Adding cookie_store v0.21.1
      Adding core-foundation v0.9.4
      Adding data-url v0.3.1
      Adding document-features v0.2.11
      Adding h2 v0.4.8
      Adding litrs v0.4.1
      Adding psl-types v2.0.11
      Adding publicsuffix v2.3.0
      Adding system-configuration v0.6.1
      Adding system-configuration-sys v0.6.0
      Adding tauri-plugin-fs v2.2.0
      Adding tauri-plugin-http v2.3.0
      Adding tokio-macros v2.5.0
    Info Installing NPM dependency "@tauri-apps/plugin-http@>=2"...
npm WARN tar TAR_ENTRY_ERROR UNKNOWN: unknown error, open 'D:\src\http3-test\node_modules\csstype\LICENSE'
npm WARN tar TAR_ENTRY_ERROR UNKNOWN: unknown error, open 'D:\src\http3-test\node_modules\react\LICENSE'
npm WARN tar TAR_ENTRY_ERROR UNKNOWN: unknown error, open 'D:\src\http3-test\node_modules\csstype\index.js.flow'
npm WARN tar TAR_ENTRY_ERROR UNKNOWN: unknown error, open 'D:\src\http3-test\node_modules\react\index.js'
npm WARN tar TAR_ENTRY_ERROR EPERM: operation not permitted, unlink 'D:\src\http3-test\node_modules\rollup\dist\shared\index.js.DELETE.b9028c845ffc584fbb068805a7d58e0a'
npm WARN tar TAR_ENTRY_ERROR EPERM: operation not permitted, unlink 'D:\src\http3-test\node_modules\react-dom\cjs\react-dom-server.browser.development.js.DELETE.76960b8d49de689888a42ede9c85b4e1'
npm WARN tar TAR_ENTRY_ERROR EPERM: operation not permitted, unlink 'D:\src\http3-test\node_modules\react-dom\umd\react-dom-server.browser.development.js.DELETE.1d650941dcfc97f45f5af66203d98360'
npm WARN tar TAR_ENTRY_ERROR EPERM: operation not permitted, unlink 'D:\src\http3-test\node_modules\@types\react\index.d.ts.DELETE.6c7871ba6cbe85ffe9516d2f2b26e620'
    Added permission `http:default` to `default` at D:\src\http3-test\src-tauri\capabilities\default.json
    Info Adding plugin to D:\src\http3-test\src-tauri\src/lib.rs
    Info Running `cargo fmt`...
  • add reqwest
PS D:\src\http3-test> cd .\src-tauri\
PS D:\src\http3-test\src-tauri> cargo add reqwest --features http3
    Updating crates.io index
      Adding reqwest v0.12.12 to dependencies                                                                                                                                                                                                                                                                 
             Features:
             + __rustls
             + __rustls-ring
             + __tls
             + charset
             + default-tls
             + h2
             + http2
             + http3
             + macos-system-configuration
             + rustls-tls-manual-roots
             + rustls-tls-manual-roots-no-provider
             22 deactivated features
     Locking 21 packages to latest compatible versions
      Adding errno v0.3.10
      Adding fastrand v2.3.0
      Adding foreign-types v0.3.2
      Adding foreign-types-shared v0.1.1
      Adding futures v0.3.31
      Adding h3 v0.0.6
      Adding h3-quinn v0.0.7
      Adding hyper-tls v0.6.0
      Adding linux-raw-sys v0.4.15
      Adding native-tls v0.2.14
      Adding openssl v0.10.71
      Adding openssl-macros v0.1.1
      Adding openssl-probe v0.1.6
      Adding openssl-sys v0.9.106
      Adding rustix v0.38.44
      Adding schannel v0.1.27
      Adding security-framework v2.11.1
      Adding security-framework-sys v2.14.0
      Adding tempfile v3.17.1
      Adding tokio-native-tls v0.3.1
      Adding vcpkg v0.2.15
  • last setting env and run you can get panic like this
error: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md
note: rustc 1.84.1 (e71f9a9a9 2025-01-27) running on x86_64-pc-windows-msvc
note: compiler flags: --crate-type lib -C embed-bitcode=no -C debuginfo=2
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [optimized_mir] optimizing MIR for `commands::fetch::{closure#0}`
#1 [layout_of] computing layout of `{async fn body of commands::fetch<R>()}`
#2 [mir_drops_elaborated_and_const_checked] elaborating drops for `commands::fetch`
#3 [analysis] running analysis passes on this crate
end of query stack
  • at last my cargo.toml is
[package]
name = "http3-test"
version = "0.1.0"
description = "A Tauri App"
authors = ["you"]
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lib]
# The `_lib` suffix may seem redundant but it is necessary
# to make the lib name unique and wouldn't conflict with the bin name.
# This seems to be only an issue on Windows, see https://github.com/rust-lang/cargo/issues/8519
name = "http3_test_lib"
crate-type = ["staticlib", "cdylib", "rlib"]

[build-dependencies]
tauri-build = { version = "2", features = [] }

[dependencies]
tauri = { version = "2", features = [] }
tauri-plugin-shell = "2"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
tauri-plugin-http = "2"
reqwest = { version = "0.12.12", features = ["http3"] }

OS: Windows 11 x64
rustc: rustc 1.84.1 (e71f9a9a9 2025-01-27)

@Wan9xy
Copy link
Author

Wan9xy commented Mar 6, 2025

Can you make a repro I can test with?

Sorry, I forget a link.
test-http3-and-tauri

@amrbashir
Copy link
Member

amrbashir commented Mar 7, 2025

This is not an issue with the plugin (or cargo I think) since I can activate the http3 feature, the panic means the feature is actually active, however not sure why it panics.

I'd suggest testing reqwest directly in a new non-tauri cargo project and if issue persists, get in contact with reqwest developer.

@amrbashir amrbashir closed this Mar 7, 2025
@Wan9xy
Copy link
Author

Wan9xy commented Mar 7, 2025

This is not an issue with the plugin (or cargo I think) since I can activate the http3 feature, the panic means the feature is actually active, however not sure why it panics.

I'd suggest testing reqwest directly in a new non-tauri cargo project and if issue persists, get in contact with reqwest developer.
@amrbashir
So currently in my project, when the tauri-http-plugin is not activated and only reqwest is used with http3 enabled, no panic occurs. However, my project needs to use the js bridge provided by the plugin, which is why I'm creating this pull request. I want to import tauri-http-plugin while enabling reqwest's http3 feature, so I can use reqwest in both Rust and JavaScript. Since this panic only occurs in the reqwest environment, I don't have a way to properly describe or explain the cause of this failure to submit it as an issue to the reqwest repository.

@amrbashir
Copy link
Member

I definitely see the panic on my side as well, but as the error states, it is a compiler bug that should be reported to rust compiler.

@Wan9xy
Copy link
Author

Wan9xy commented Mar 11, 2025

I definitely see the panic on my side as well, but as the error states, it is a compiler bug that should be reported to rust compiler.

I commit a issue to rust repo, it got a P-medium label now.

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