Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
AlexHaxe opened this issue Mar 21, 2019 · 1 comment
Open

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

AlexHaxe opened this issue Mar 21, 2019 · 1 comment

Comments

@AlexHaxe
Copy link

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.

@fal-works
Copy link

Found something similar:

  • Haxe 4.1.0
  • hxnodejs 12.1.0
  • Windows 10
  • Node.js 13.12.0

Sys.stdin().readUntil() and Sys.stdin().readLine() seem to cause infinite loops at EOF because they expect Eof to be thrown but fs.readSync() just returns 0.
However I'm not sure what would be the proper way to fix this.

Might be related: nodejs/node#8024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants