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

build(next/core): allow to specify tls backend for reqwest #2994

Merged
merged 2 commits into from
Dec 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
38 changes: 38 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,8 @@ modularize_imports = { version = "0.25.10" }
mdxjs = { version = "0.1.4" }
next-dev = { path = "crates/next-dev", version = "0.1.0" }
node-file-trace = { path = "crates/node-file-trace", version = "0.1.0" }
# Be careful when selecting tls backend, including change default tls backend.
# If you changed, must verify with ALL build targets with next-swc to ensure
# it works. next-swc have various platforms, some doesn't support native (using openssl-sys)
# and some aren't buildable with rustls.
reqwest = { version = "0.11.13", default-features = false }
2 changes: 2 additions & 0 deletions crates/next-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ turbo-tasks-build = { path = "../turbo-tasks-build" }

[features]
next-font-local = []
native-tls = ["turbo-tasks-fetch/native-tls"]
rustls-tls = ["turbo-tasks-fetch/rustls-tls"]
9 changes: 8 additions & 1 deletion crates/next-dev/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ name = "mod"
harness = false

[features]
default = ["cli", "custom_allocator"]
# By default, we enable native-tls for reqwest downstream trasntive features.
# This is for the convinience for all of daily dev workflow i.e running
# `cargo xxx` without explicitly specifying features, not that we want to
# promote this as default backend. Actual configuration is done when build next-swc,
# and also turbopack standalone when we have it.
default = ["cli", "custom_allocator", "native-tls"]
cli = []
serializable = []
tokio_console = [
Expand All @@ -30,6 +35,8 @@ tokio_console = [
profile = []
custom_allocator = ["turbo-malloc/custom_allocator"]
next-font-local = ["next-core/next-font-local"]
native-tls = ["next-core/native-tls"]
rustls-tls = ["next-core/rustls-tls"]

[dependencies]
anyhow = "1.0.47"
Expand Down
8 changes: 7 additions & 1 deletion crates/turbo-tasks-fetch/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,17 @@ edition = "2021"
[lib]
bench = false

[features]
# Allow to configure specific tls backend for reqwest.
# See top level Cargo.toml for more details.
native-tls = ["reqwest/native-tls"]
rustls-tls = ["reqwest/rustls-tls"]

[dependencies]
anyhow = "1.0.47"
indexmap = { workspace = true }
lazy_static = "1.4.0"
reqwest = "0.11.13"
reqwest = { workspace = true }
serde = "1.0.136"
tokio = "1.11.0"
turbo-tasks = { path = "../turbo-tasks" }
Expand Down
14 changes: 14 additions & 0 deletions crates/turbo-tasks-fetch/build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
use turbo_tasks_build::generate_register;

#[cfg(any(feature = "native-tls", feature = "rustls-tls"))]
fn check_tls_config() {
// do nothing
}
#[cfg(not(any(feature = "native-tls", feature = "rustls-tls")))]
fn check_tls_config() {
panic!("You must enable one of the TLS features: native-tls or rustls-tls");
}

fn main() {
generate_register();

// Check if tls feature for reqwest is properly configured.
// Technically reqwest falls back to non-tls http request if none of the tls
// features are enabled, But we won't allow it.
check_tls_config();
}