Asynchronous printing hangs the server
Nobody has claimed this yet.
- Dominant language
- Lean
- Stars
- 9.2k
- Forks
- 990
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 175
Description
Prerequisites
- Put an X between the brackets on this line if you have done all of the following:
- Checked that your issue isn't already filed.
- Reduced the issue to a self-contained, reproducible test case.
Description
Printing text asynchronously (e.g., a IO.println run through IO.asTask) causes the Lean server to hang.
Steps to Reproduce
Run the following code via the Lean server (e.g., in VSCode) to observe the server hanging:
#eval show IO _ from do
IO.wait <| ← IO.asTask <| IO.println "test"
Expected behavior:
To print "test" either as a diagnostic or in the output panel.
Actual behavior:
The server hangs.
Reproduces how often:
Always.
Versions
Windows 10 20H2
Lean (version 4.0.0-nightly-2021-10-23, commit a741a3dfd422, Release)
Additional Information
I suspect this is actually due to the same problem as #640. That is, I suspect that the asynchronous print is not being properly redirected (due to being in a separate thread) and is thus printing to normal stdout,. This, as #640 shows, causes the server to hang.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Run the provided Lean snippet through the Lean server, for example in VSCode, and compare the behavior with the related issue #640. Trace how asynchronous IO.println output is redirected or handled by the server. Done means the snippet prints "test" as a diagnostic or in the output panel without hanging the server.
Written by the indexing model from the issue text.
Assessment
- Domain
- developer-experience
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100