Skip to content
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

[bug] HTTP 100 response inconsistent between default and "reqwest-client" #4796

Closed
KaKi87 opened this issue Jul 29, 2022 · 8 comments
Closed
Labels
status: upstream This issue is blocked by upstream dependencies and we need to wait or contribute upstream fixes type: bug

Comments

@KaKi87
Copy link

KaKi87 commented Jul 29, 2022

Describe the bug

Depending on whether Cargo.toml > tauri > features contains ["api-all"] or ["api-all", "reqwest-client"], the http API behaves inconsistently when receiving an HTTP 100 response.

Reproduction

Make an http request that will return status code 100.

Expected behavior

Both configurations behaves consistently (either with a success or error response).

Platform and versions

Environment
  › OS: Ubuntu 21.10 X64
  › Node.js: 16.16.0
  › npm: 8.11.0
  › pnpm: Not installed!
  › yarn: 1.22.19
  › rustup: 1.24.3
  › rustc: 1.61.0
  › cargo: 1.61.0
  › Rust toolchain: stable-x86_64-unknown-linux-gnu 

Packages
  › @tauri-apps/cli [NPM]: 1.0.2
  › @tauri-apps/api [NPM]: 1.0.1
  › tauri [RUST]: 1.0.2,
  › tauri-build [RUST]: 1.0.2,
  › tao [RUST]: 0.12.1,
  › wry [RUST]: 0.19.0,

App
  › build-type: bundle
  › CSP: default-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self' img-src: 'self'
  › distDir: ../dist
  › devPath: http://localhost:1234/

App directory structure
  ├─ src
  ├─ .git
  ├─ .parcel-cache
  ├─ src-tauri
  ├─ .idea
  ├─ dist
  └─ node_modules

Stack trace

Network Error: error sending request for url (http://localhost:5678/100): connection closed before message completed

Additional context

Here are screenshots of this inconsistency being spotted while running axios-tauri-adapter-test :

@KaKi87 KaKi87 added status: needs triage This issue needs to triage, applied to new issues type: bug labels Jul 29, 2022
@lucasfernog lucasfernog added status: upstream This issue is blocked by upstream dependencies and we need to wait or contribute upstream fixes and removed status: needs triage This issue needs to triage, applied to new issues labels Jul 31, 2022
@lucasfernog
Copy link
Member

This looks like a hyper issue (hyper is used by reqwest). See hyperium/hyper#2565 and hyperium/hyper#2743

There's not much we can do, the alternative is already there if you can use attohttpc.

@KaKi87
Copy link
Author

KaKi87 commented Aug 1, 2022

Is it possible to know from JS what Rust client is used ? (so I could perform conditional assertion)

@FabianLars
Copy link
Member

FabianLars commented Aug 1, 2022

That's only accessible in rust. So you either have to send that info from the rust side to js, NVM it isn't unless you can parse the cargo.toml file.
or idk do a dummy request and check the responses (if the clients do something differently that is).

(I'd still like to merge both clients into a custom hyper one, but so much could go wrong 😅)

@KaKi87
Copy link
Author

KaKi87 commented Aug 1, 2022

So, using toml,
This :

[package]
name = "app"
version = "0.1.0"
description = "A Tauri App"
authors = ["you"]
license = ""
repository = ""
default-run = "app"
edition = "2018"
build = "src/build.rs"

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

[build-dependencies]
tauri-build = { version = "1.0.0-beta.4", features = [] }

[dependencies]
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.0.0-beta.8", features = ["api-all"] }

[features]
default = [ "custom-protocol" ]
custom-protocol = [ "tauri/custom-protocol" ]

Turns into this :

{
    "package": {
        "name": "app",
        "version": "0.1.0",
        "description": "A Tauri App",
        "authors": [
            "you"
        ],
        "license": "",
        "repository": "",
        "default-run": "app",
        "edition": "2018",
        "build": "src/build.rs"
    },
    "build-dependencies": {
        "tauri-build": {
            "version": "1.0.0-beta.4",
            "features": []
        }
    },
    "dependencies": {
        "serde_json": "1.0",
        "serde": {
            "version": "1.0",
            "features": [
                "derive"
            ]
        },
        "tauri": {
            "version": "1.0.0-beta.8",
            "features": [
                "api-all"
            ]
        }
    },
    "features": {
        "default": [
            "custom-protocol"
        ],
        "custom-protocol": [
            "tauri/custom-protocol"
        ]
    }
}

And this :

[package]
name = "app"
version = "0.1.0"
description = "A Tauri App"
authors = ["you"]
license = ""
repository = ""
default-run = "app"
edition = "2018"
build = "src/build.rs"

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

[build-dependencies]
tauri-build = { version = "1.0.0-beta.4", features = [] }

[dependencies]
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.0.0-beta.8", features = ["api-all", "reqwest-client"] }

[features]
default = [ "custom-protocol" ]
custom-protocol = [ "tauri/custom-protocol" ]

Into this :

{
    "package": {
        "name": "app",
        "version": "0.1.0",
        "description": "A Tauri App",
        "authors": [
            "you"
        ],
        "license": "",
        "repository": "",
        "default-run": "app",
        "edition": "2018",
        "build": "src/build.rs"
    },
    "build-dependencies": {
        "tauri-build": {
            "version": "1.0.0-beta.4",
            "features": []
        }
    },
    "dependencies": {
        "serde_json": "1.0",
        "serde": {
            "version": "1.0",
            "features": [
                "derive"
            ]
        },
        "tauri": {
            "version": "1.0.0-beta.8",
            "features": [
                "api-all",
                "reqwest-client"
            ]
        }
    },
    "features": {
        "default": [
            "custom-protocol"
        ],
        "custom-protocol": [
            "tauri/custom-protocol"
        ]
    }
}

Do I only have to check whether dependencies.tauri.features includes reqwest-client, or are there other possible configurations, like maybe one that explicitly enables the default client ?

Thanks

@FabianLars
Copy link
Member

If the package can handle this syntax too (it's part of the toml standard, so packages should support it)

[dependencies.tauri]
version = ""
features = []

then you should be covered.

The client is at the moment only changeable via the reqwest-client flag.
the only thing that could be a problem is if users create their own feature flags that enable it, like we do here with the custom-protocol 🤔

@KaKi87
Copy link
Author

KaKi87 commented Aug 1, 2022

If the package can handle this syntax too (it's part of the toml standard, so packages should support it)

[dependencies.tauri]
version = ""
features = []

then you should be covered.

That works too, thanks.

The client is at the moment only changeable via the reqwest-client flag.

Alright !

the only thing that could be a problem is if users create their own feature flags that enable it, like we do here with the custom-protocol thinking

Something like this ?

[features]
default = [ "custom-protocol", "foobar" ]
custom-protocol = [ "tauri/custom-protocol" ]
foobar = ["reqwest-client"]

If yes, I'm pretty sure I can parse it as well, using some loops.

@FabianLars
Copy link
Member

Yes, something like this. Well actually it would be foobar = ["tauri/reqwest-client"] but whatever.
The last problem would be if it's not a default feature, but activated via a cli switch. But that should be pretty rare i guess and can be solved via documentation.

@KaKi87
Copy link
Author

KaKi87 commented Aug 3, 2022

Alright, thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: upstream This issue is blocked by upstream dependencies and we need to wait or contribute upstream fixes type: bug
Projects
None yet
Development

No branches or pull requests

3 participants