Skip to content

Running a server #381

Description

@silverpill

When I run a server, it doesn't listen to connections.

I already described the problem in #330 (comment), 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 #360

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions