-
Notifications
You must be signed in to change notification settings - Fork 64
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
Relative file path loads on Windows not resolving as expected for Rust projects #360
Comments
Hi thanks for posting! You've hit two features that are currently unsupported in JCO:
We're actively working on techniques for (2) in this project, including through the WASI-Virt project for virtualizing WASI in the browser. It won't be overnight, but this experience will improve very soon now that Node.js support is stable. For (1), new threading specifications for Wasm will solve this in due course, but I can't offer any roadmap currently unfortunately. |
Thanks for the fast reply, @guybedford . I am aware of WASI threads proposal hasn't reached phase 4, but some questions seemed to be unsolved yet :) please let me clarify...
|
Both network IO and file IO should work on Node.js. If you have any example that is failing I would be happy to take a look as that would be a bug. |
It's this repository right here: After cloning the repo, all the commands are written in |
It is using threads though - https://github.com/temeddix/jco-test/blob/main/src/common.rs#L24 ? I thought you said the problem was something other than the threads support? Do you have an example that doesn't use threads to verify that? |
Even if I remove the thread code like this pub fn start() {
println!("YAHOOOO");
// Current directory
let current_dir = env::current_dir().unwrap();
println!("{current_dir:?}");
// Time IO
let now = std::time::Instant::now();
println!("{now:?}");
// Network IO
let url = "http://jsonplaceholder.typicode.com/todos/1";
let response_body = request_web(url);
println!("{response_body}");
// File IO
let test_text = std::fs::read("nodejs/file_test.txt");
println!("{test_text:?}");
} It gives results like this on Node.js
I'm pretty sure that things were working well about a couple of months ago. Yesterday I tried |
Thanks, this is a Windows-specific pathing bug, I'll take a look. |
Let me note that Network I/O is not working as well, like the output below
which derives from this Rust code fn request_web(url: &str) -> String {
// Parse the URL to extract the domain and path
let (domain, path) = parse_url(url).expect("Invalid URL");
// Establish a TCP connection to the domain
if let Ok(mut stream) = TcpStream::connect(format!("{}:80", domain)) {
// Prepare the HTTP request
let request = format!(
"GET {} HTTP/1.1\r\n\
Host: {}\r\n\
Connection: close\r\n\
\r\n",
path, domain
);
// Send the HTTP request
if stream.write(request.as_bytes()).is_ok() {
// Read the response
let mut response = String::new();
let mut reader = BufReader::new(&stream);
if reader.read_to_string(&mut response).is_ok() {
// Print the response
let response_parts: Vec<&str> = response.split("\r\n\r\n").collect();
if response_parts.len() >= 2 {
let body = response_parts[1];
return body.to_owned();
} else {
return String::from("No valid response (1)");
}
} else {
return String::from("No valid response (2)");
}
} else {
return String::from("No valid response (3)");
}
} else {
return String::from("No valid response (4)");
}
} |
There is probably more information about the error in the Err returned from TcpStream::connect, and other places - you might want to change that program to return Result<String, anyhow::Error> and use the debug print of the Err on failure. But additionally, the rust std TcpStream is not yet connected to preview 2 wasi-sockets, right now you have to use wasi-sockets bindings directly. Work is underway in wasi-libc that will lead to support for wasi-sockets in std. |
I've checked the fn request_web(url: &str) -> String {
// Parse the URL to extract the domain and path
let (domain, path) = parse_url(url).expect("Invalid URL");
// Establish a TCP connection to the domain
let result = TcpStream::connect(format!("{}:80", domain));
println!("{result:?}");
}
But I see that |
Hi. First, I would like to thank the developers here for all the great ongoing efforts to make
wasm32-wasi
work on multiple platforms. Also congratulations for the 1.0.0 release.Since the Rinf (Rust in Flutter) project is planning to move from
wasm32-unknown-unknown
towasm32-wasi
in the future, I've been testeingjco
version 1.0.0 on my personal repository, and found out most of the things were broken, at least for me.I'm using...
You can take a look at my repo, but the Rust logic is rather simple. It just tests various I/O functionalities.
When I build and test the above repo for node.js, I get the following error: (Not only the errors, but the current directory is somewhat wrong)
When I build and test the above repo for browsers, I get the following error:
I know that support for these platforms are not finalized, but it would be nice to know which parts are supported and which parts are not yet, since
jco
have reached version 1.0.0. I've been digging in the README and docs, but couldn't find any relevant information.If I've missed anything, please let me know :)
The text was updated successfully, but these errors were encountered: