-
Notifications
You must be signed in to change notification settings - Fork 372
Open
Description
Is there an existing issue for this?
- I have searched the existing issues
What version of workers-rs are you using?
0.7.1
What version of wrangler are you using?
4.45.3
Describe the bug
when connect supabase db use ssl will error, without ssl is ok.
supabase error
✘ [ERROR] panicked at app_state.rs:90:17:
Config::new().connect_raw(socket, PassthroughTls) failed: Error {
kind: Io,
cause: Some(
Custom {
kind: Other,
error: "Error: internal error; reference = 0f689nvm9q0onk5qs9d49u2l",
},
),
}
Steps To Reproduce
use consts::r2;
use std::future::{Ready, ready};
use std::str::FromStr;
use tokio_postgres::config::Host;
use tokio_postgres::tls::TlsConnect;
use tokio_postgres::{Client, Config, NoTls};
use worker::postgres_tls::{PassthroughTls};
use worker::{Bucket, Env, SecureTransport, Socket, console_log, wasm_bindgen_futures};
env DATABASE_URL (supabase db without ssl string)
DATABASE_URL=postgresql://USER:[email protected]:5432/postgres
without ssl connect code
let database_url: String = match self.env.secret("DATABASE_URL") {
Ok(v) => v.to_string(),
Err(e) => {
panic!("env DATABASE_URL not found: {e}");
}
};
console_log!("{}", database_url);
let config: Config = Config::from_str(database_url.as_str())
.unwrap_or_else(|e| panic!("Config::from_str failed: {e:?}"));
let host: String = match config.get_hosts()[0].clone() {
Host::Tcp(v) => v,
#[allow(unreachable_patterns)]
_ => {
panic!("Config::get_hosts only support tcp");
}
};
let port: u16 = config.get_ports()[0];
let socket: Socket = Socket::builder()
// .secure_transport(SecureTransport::StartTls)
.secure_transport(SecureTransport::Off)
.connect(host, port)
.unwrap_or_else(|e| {
panic!("Socket::builder failed: {e:?}");
});
// PassthroughTls
let (client, connection) = config.connect_raw(socket, NoTls).await.unwrap_or_else(|e| {
panic!("Config::new().connect_raw(socket, PassthroughTls) failed: {e:#?}");
});
env DATABASE_URL (neno db ssl string)
DATABASE_URL=postgresql://USER:[email protected]/next_sight?sslmode=require
env DATABASE_URL (supabase db ssl string)
DATABASE_URL=postgresql://USER:[email protected]:5432/postgres?sslmode=require
ssl connect code
let database_url: String = match self.env.secret("DATABASE_URL") {
Ok(v) => v.to_string(),
Err(e) => {
panic!("env DATABASE_URL not found: {e}");
}
};
console_log!("{}", database_url);
let config: Config = Config::from_str(database_url.as_str())
.unwrap_or_else(|e| panic!("Config::from_str failed: {e:?}"));
let host: String = match config.get_hosts()[0].clone() {
Host::Tcp(v) => v,
#[allow(unreachable_patterns)]
_ => {
panic!("Config::get_hosts only support tcp");
}
};
let port: u16 = config.get_ports()[0];
let socket: Socket = Socket::builder()
.secure_transport(SecureTransport::StartTls)
.connect(host, port)
.unwrap_or_else(|e| {
panic!("Socket::builder failed: {e:?}");
});
// PassthroughTls
let (client, connection) = config
.connect_raw(socket, PassthroughTls)
.await
.unwrap_or_else(|e| {
panic!("Config::new().connect_raw(socket, PassthroughTls) failed: {e:#?}");
});
Metadata
Metadata
Assignees
Labels
No labels