rustyscript
rustyscript copied to clipboard
Running a server
When I run a server, it doesn't listen to connections.
I already described the problem in https://github.com/rscarson/rustyscript/issues/330#issuecomment-2727589434, but that issue was closed, so I am opening a new one.
Example:
use rustyscript::{Error, Module, Runtime};
fn main() -> Result<(), Error> {
let module = Module::new(
"test.js",
r#"
import * as net from "node:net"
export default function testServer() {
const server = net.createServer()
server.listen(8124, () => {
console.log("server bound")
server.close()
})
}
"#
);
let mut runtime = Runtime::new(Default::default())?;
let handle = runtime.load_module(&module)?;
let () = runtime.call_entrypoint(
&handle,
&(),
)?;
Ok(())
}
When I run the same function in Deno, it prints "server bound" and exits, as expected. But with rustyscript it doesn't print "server bound".
This might be related to https://github.com/rscarson/rustyscript/issues/360
Apologies, a fix in 0.12.0 was designed to address this
On 0.12 you still see it?
Yes, I am using 0.12.2 now
Ok I will investigate