rescript-lang / rescript-vscode

Official VSCode plugin for ReScript
MIT License
329 stars 56 forks source link

Incremental type checking not working on a specific project #1022

Closed lucas-teks closed 4 months ago

lucas-teks commented 4 months ago

Hi, I've just switched to a fresh Mac OS install and after cloning my repo the rescript.settings.incrementalTypechecking.enabled is bugging out in this specific project pos/.

I couldn't reproduce the issue as I have tried upon a clean minimalistic codebase with the same rescript version 10.1.1 that I am using in pos/ and it works perfectly. Both projects without local .vscode/settings.json, only using my user settings.json to fetch the extension feature flag.

What is confusing me is that the extension seem to not be crashing because the inlay hint feature is still working so is the formatting upon save and that the incremental type checking feature is working on the same codebase pos/ upon my Ubuntu OS.

Whenever I start editing a file, before saving, the extension instantly sends a problem/error at the top of the edited file (simply adding a whitespace will trigger this). This problem/error will stay until I restart the language server.

Here's a screen that illustrates the issue on a random file of my codebase:

image

Thank you if you have any idea for me 🙌

lucas-teks commented 4 months ago

When checking the runtime status tab of the extension there is a Uncaught Error: message must be set logged. This happens both in the pre-release/stable or earlier versions of the extension like the 1.18 (1yo).

zth commented 4 months ago

Can you turn on debugging for incremental type checking and check the output console? It's an option in the settings.

To me this sounds like something errors when it tries to figure out all of your project sources. Could you open lib/build.ninja and paste the line that starts with command = just under the line that says rule mij_dev?

lucas-teks commented 4 months ago

Here are the steps done before fetching the logs:

Debug output:

Node.js v20.9.0
[Info  - 14:52:03] Connection to server got closed. Server will restart.
true
Recreating incremental file folder
can't find module Qs-Pos
can't find module Qs-Pos
Updated: /Users/lucasteixeira/Documents/GitHub/pos/src/externals/Qs.res
<ref *1> Error: spawnSync /Users/lucasteixeira/Documents/GitHub/pos/node_modules/@rolandpeelen/rewatch/rewatch ENOENT
    at Object.spawnSync (node:internal/child_process:1124:20)
    at spawnSync (node:child_process:914:24)
    at Object.execFileSync (node:child_process:957:15)
    at Object.func (node:electron/js2c/node_init:2:2214)
    at /Users/lucasteixeira/.vscode/extensions/chenglou92.rescript-vscode-1.54.0/server/out/cli.js:37:3467
    at new Promise (<anonymous>)
    at Bv (/Users/lucasteixeira/.vscode/extensions/chenglou92.rescript-vscode-1.54.0/server/out/cli.js:37:2755)
    at _h (/Users/lucasteixeira/.vscode/extensions/chenglou92.rescript-vscode-1.54.0/server/out/cli.js:37:5891)
    at zv (/Users/lucasteixeira/.vscode/extensions/chenglou92.rescript-vscode-1.54.0/server/out/cli.js:37:5175)
    at Rh (/Users/lucasteixeira/.vscode/extensions/chenglou92.rescript-vscode-1.54.0/server/out/cli.js:42:573) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawnSync /Users/lucasteixeira/Documents/GitHub/pos/node_modules/@rolandpeelen/rewatch/rewatch',
  path: '/Users/lucasteixeira/Documents/GitHub/pos/node_modules/@rolandpeelen/rewatch/rewatch',
  spawnargs: [
    '--rescript-version',
    '10.1.1',
    '--compiler-args',
    '/Users/lucasteixeira/Documents/GitHub/pos/src/externals/Qs.res'
  ],
  error: [Circular *1],
  status: null,
  signal: null,
  output: null,
  pid: 0,
  stdout: null,
  stderr: null
}
can't find module Qs-Pos

I have removed unnecessary src/* tests/*:

command = /Users/lucasteixeira/Documents/GitHub/pos/node_modules/rescript/darwinarm64/bsc.exe
  -bs-ns Pos 
  -I .
  -I src
  -I src/externals
  -I /Users/lucasteixeira/Documents/GitHub/pos/node_modules/@reasonml-community/graphql-ppx/lib/ocaml        
  -I /Users/lucasteixeira/Documents/GitHub/pos/node_modules/@rescript/react/lib/ocaml 
  -I /Users/lucasteixeira/Documents/GitHub/pos/node_modules/rescript-apollo-client/lib/ocaml 
  -I /Users/lucasteixeira/Documents/GitHub/pos/node_modules/rescript-future/lib/ocaml 
  -I /Users/lucasteixeira/Documents/GitHub/pos/node_modules/rescript-react-native/lib/ocaml

  -bs-super-errors -open Belt -w -3-4-9-20-30-40-41-42-102-103+26+27+32+33+34+60 -warn-error +A-3-26-27-32-33-34-60
  -bs-gentype -bs-package-name pos -bs-package-output es6:$in_d:.bs.js -bs-v $g_finger $i
lucas-teks commented 4 months ago

Now I see the logs, I remember having tried out rewatch on this project, I recloned the repo and it's all good now! It must have created some conflicts. Please, do you know if simply just installing rewatch on the dev deps and using its command instead of rescript one is the correct way of proceeding? 🙏

zth commented 4 months ago

Ahh yes, this is a bit unfortunate, and comes from that there's something lingering in the project that makes the incremental type checking mode assume you're running Rewatch. I've hit something similar before.

We'll have to see if we can make that a bit more robust.