Skip to content

for await from console only works once #16248

@fs-c

Description

@fs-c

What version of Bun is running?

1.1.42+50eec0025

What platform is your computer?

Microsoft Windows NT 10.0.22631.0 x64

What steps can reproduce the bug?

using console as an async iterator only works "the first time", this is a regression of #5175

export async function waitForUserInput(prompt) {
    console.log(prompt);

    for await (const line of console) {
        console.log(`pong ${line}`);

        if (line.trim() === 'exit') {
            return;
        }
    }
}

await waitForUserInput('first');
await waitForUserInput('second');

What is the expected behavior?

i would expect to also have the echo work for the second call of waitForUserInput

What do you see instead?

second is printed to console (function is called) but pressing enter has no effect upon entering anything in the terminal

Additional information

i suspect that this is windows-specific, since i know that in the past this has worked for me on mac before

but it might also be a regression in a recent version of bun

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions