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

fix(cli): Rework JSOO hacks to ensure stdin always gets data #614

Merged
merged 1 commit into from
Apr 21, 2021
Merged

Conversation

phated
Copy link
Member

@phated phated commented Apr 21, 2021

Thanks to some amazing detective work by @ng-marcus - we discovered that doing readSync on the 0 file descriptor doesn't always work in node (depending on how values are pushed into stdin); however, readFileSync on the 0 file descriptor always works as expected!

With this discovery, I reworked the way we workaround JSOO's mock stdin by using their Sys_js.set_channel_filler API, which then just calls fs.readFileSync(0). Unfortunately, those APIs can't be using in a native build, so I needed to do some dune trickery to concat the workaround to the top of grainc.re when we are building for JS.

I wonder if @hhugo has a better way to handle this. I'm happy to open an issue for cleanup.

@phated phated requested a review from a team April 21, 2021 03:25
Copy link
Member

@ospencer ospencer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huzzah!

@hhugo
Copy link

hhugo commented Apr 21, 2021

It would be nice to have this working out of the box when using node. Tuning the Jsoo runtime should do the trick

@hhugo
Copy link

hhugo commented Apr 21, 2021

Do you want to give it a go and open a PR ? (or at least open an issue)

@hhugo
Copy link

hhugo commented Apr 21, 2021

it seems the patch to caml_make_path should also be upstreamed

@github-actions github-actions bot mentioned this pull request May 31, 2022
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

Successfully merging this pull request may close these issues.

3 participants