Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

example_hs/wasi_http_fetch.js returns "InternalError: invalid socket address syntax" on macOS #141

Open
tritonrc opened this issue Jun 22, 2024 · 1 comment

Comments

@tritonrc
Copy link

I was playing with wasmedge + quickjs last night (thank you all for the great work here!) when I ran into an error with the http fetch examples.

Each one returned "InternalError: invalid socket address syntax"

After digging around on the internet I stumbled on to_socket_addrs (line 475 in src/internal_module/wasi_net_module.rs) as the culprit.

Changing this line to the following:

diff --git a/src/internal_module/wasi_net_module.rs b/src/internal_module/wasi_net_module.rs
index 3991f33..764ddb7 100644
--- a/src/internal_module/wasi_net_module.rs
+++ b/src/internal_module/wasi_net_module.rs
@@ -472,7 +472,7 @@ fn js_nsloopup(ctx: &mut Context, _this: JsValue, param: &[JsValue]) -> JsValue
     let node = param.get(0);
     let service = param.get(1);
     if let (Some(JsValue::String(node)), Some(JsValue::String(service))) = (node, service) {
-        let r = format!("{}:{}", node.as_str(), service.as_str()).to_socket_addrs();
+        let r = (node.as_str(), service.as_str().parse::<u16>().unwrap_or(0)).to_socket_addrs();
         match r {
             Ok(addr_vec) => {
                 let mut array = ctx.new_array();

did the trick and I was able to run the http fetch tests successfully on my Mac.

@L-jasmine
Copy link
Collaborator

Thank you for your questions and solutions. I think something has gone wrong at a lower level. I will check it

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants