ocaml / ocaml/dune

Restarting OCaml LSP caused Internal error: attempting to write to a closed channel

Open
#8,968 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

engine needs-investigation watch mode
Dominant language
OCaml
Stars
1.9k
Forks
500
Avg merge
15h 21m
Merged PRs (30d)
277

Description

Internal error, please report upstream including the contents of _build/log.
Description:
  ("attempting to write to a closed channel",
  { sexp =
      [ [ [ "id"; [ [ "poll"; [ "auto"; "0" ] ]; [ "i"; "0" ] ] ]
        ; [ "result"
          ; [ "ok"
            ; [ "Some"
              ; [ "in_progress"
                ; [ [ "complete"; "0" ]; [ "remaining"; "0" ] ]
                ]
              ]
            ]
          ]
        ]
      ]
  })
Raised at Stdune__Code_error.raise in file
  "otherlibs/stdune/src/code_error.ml", line 11, characters 30-62
Called from Fiber__Scheduler.exec in file "otherlibs/fiber/src/scheduler.ml",
  line 73, characters 8-11

I must not crash.  Uncertainty is the mind-killer. Exceptions are the
little-death that brings total obliteration.  I will fully express my cases. 
Execution will pass over me and through me.  And when it has gone past, I
will unwind the stack along its path.  Where the cases are handled there will
be nothing.  Only I will remain.
Success, waiting for filesystem changes...

Reproduction

  1. Start VSCode with OCaml LSP, then dune in watch mode (-w)
  2. Run VSCode command OCaml: Restart Language Server
  3. Make some code change and save
  4. Observe dune output

Reproduced with ahrefs/devkit. I don't recall seeing this before switching to dune 3.10.0, and I restart the LSP client all the time due to out-dated/stale state in the client.

Specifications

> dune --version                                                
3.10.0                                                                                                                                          
> ocamlc --version                                                       
4.14.0                                                                                                                                                                             
> lsb_release -a                                                     
No LSB modules are available.                                                                                                                   
Distributor ID: Debian                                                                                                                          
Description:    Debian GNU/Linux 11 (bullseye)                                                                                                  
Release:        11                                                                                                                              
Codename:       bullseye        

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with VSCode, OCaml LSP, and dune 3.10.0 in watch mode using the listed restart and save steps. Start by reading otherlibs/fiber/src/scheduler.ml and otherlibs/stdune/src/code_error.ml around the reported stack frames. Done means restarting the language server and saving a change no longer causes dune to report an internal error or write to a closed channel.

Written by the indexing model from the issue text.

Assessment

Tech stack
ocaml
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.