Skip to content

ModuleConfig.WithStdin() Does not use the specified Stdin. #99

@ASparkOfFire

Description

@ASparkOfFire

I am trying to do something like this.

        stdin := bytes.NewReader([]byte("Hello, World\n"))
        instance, err := runtime.InstantiateModule(ctx, wasmModule, wazero.NewModuleConfig().
                WithStdin(stdin).
                WithStdout(os.Stdout).
                WithStderr(os.Stderr).
                WithArgs(args...))

However, the module still reads from os.Stdin instead of specified io.Writer. Any ideas?

Could this be related to the imports.Builder or sockets extension overriding the stdin configuration? Is there a way to force the module to use the custom io.Reader provided to WithStdin?

Steps to Reproduce:

1. Create a wasm module expecting stdin input.
2. Instantiate the module with `ModuleConfig.WithStdin` as above.
3. Observe that the module reads from actual stdin (`os.Stdin`) rather than the specified reader.

Expected behavior:
The module reads stdin input exclusively from the provided io.Reader.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions