Open alexkornitzer opened 7 months ago
I can also reproduce this behavior using Bun as the runtime for my chess engine, postbot.
Since Bun v1.0.31, the engine has stopped working with BanksiaGUI or the lichess-bot wrapper. According to the logs, it appears that stdin stops working after the first input.
Since Bun v1.0.31 which had the major IO rework, talking to Bun via an Erlang Port (https://www.erlang.org/doc/tutorial/c_port) has resulted in hangs on macOS. After investigation the issue appears to come from assumptions that Bun makes in its
FileReader
(https://github.com/oven-sh/bun/blob/main/src/bun.js/webcore/streams.zig#L3441), resulting in it setting the reader as non blocking when the file descriptor is not. This then results in a hang as thePosixBufferedReader
handles reads in a non blocking way while the read syscall is blocking, thusEAGAIN
is never raised.I have used a rather forceful approach in local testing to fix the issue which just ensures the file descriptor is non blocking (using the already present but what appears to be unused function).
I have not raised a PR for this as I understand the fix might be to handle the broken assumptions for macOS builds rather than forcing the descriptor to be non blocking.
The following was used to reproduce the error:
test.js
wrapper.sh