diff options
author | Yazan AbdAl-Rahman <yazan.abdalrahman@exalt.ps> | 2024-07-09 14:44:12 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-09 13:44:12 +0200 |
commit | c11e2c74e874af29b6ade13ee4ab51a72853d726 (patch) | |
tree | 27f43740c2331a437f72c8c8cbfb70085a2b32d9 /ext/net | |
parent | 77c5a336adde9cdf7c0ce35dd24f83f1a887570e (diff) |
fix(net): handle panic on Windows for Unix socket usage in Deno.serve() (#24423)
This PR addresses the issue where Deno.serve() panics on Windows when
trying to use a Unix socket.
Fixes #21967
Diffstat (limited to 'ext/net')
-rw-r--r-- | ext/net/lib.rs | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/ext/net/lib.rs b/ext/net/lib.rs index 3b6c05282..c0f94ce1c 100644 --- a/ext/net/lib.rs +++ b/ext/net/lib.rs @@ -158,14 +158,28 @@ mod ops_unix { macro_rules! stub_op { ($name:ident) => { #[op2(fast)] - pub fn $name() { - panic!("Unsupported on non-unix platforms") + pub fn $name() -> Result<(), std::io::Error> { + let error_msg = format!( + "Operation `{:?}` not supported on non-unix platforms.", + stringify!($name) + ); + Err(std::io::Error::new( + std::io::ErrorKind::Unsupported, + error_msg, + )) } }; ($name:ident<P>) => { #[op2(fast)] - pub fn $name<P: NetPermissions>() { - panic!("Unsupported on non-unix platforms") + pub fn $name<P: NetPermissions>() -> Result<(), std::io::Error> { + let error_msg = format!( + "Operation `{:?}` not supported on non-unix platforms.", + stringify!($name) + ); + Err(std::io::Error::new( + std::io::ErrorKind::Unsupported, + error_msg, + )) } }; } |