Skip to content

Sys.stdin().readAll() throws Blocked exception #119

Description

@AlexHaxe

I am trying to use Sys.stdin().readAll to read all data from stdin (passed by e.g. node run.js < file.txt). Apparently the last readBytes call returns 0 which prompts haxe.io.Input to throw a Blocked exception (throwing away all bytes read so far - which might not be ideal).

I haven't found any documentation for node's readSync function that talks about exceptions it might throw - I don't even know if throwing exceptions is a thing in NodeJS. But I fear Eof is never thrown, meaning any data read from stdin gets discarded.

I know that technically stdin might receive a constant stream of data, with no clear EOF in sight, so using readAll is definitely not an option in those situations and blocking is probably the correct response. Although loosing all input might not be very helpful.

I don't know if there's more places that use FileInput and if they throw a proper Eof exception when exhausting input, but at least in stdin's case it misbehaves.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions