rustyscript icon indicating copy to clipboard operation
rustyscript copied to clipboard

Running a server

Open silverpill opened this issue 4 months ago • 3 comments

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

silverpill avatar Aug 16 '25 21:08 silverpill

Apologies, a fix in 0.12.0 was designed to address this

On 0.12 you still see it?

rscarson avatar Aug 16 '25 22:08 rscarson

Yes, I am using 0.12.2 now

silverpill avatar Aug 17 '25 15:08 silverpill

Ok I will investigate

rscarson avatar Aug 17 '25 15:08 rscarson