HaxeFoundation / HaxeFoundation/hxnodejs
Sys.stdin().readAll() throws Blocked exception
- Dominant language
- Haxe
- Stars
- 177
- Forks
- 58
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.