Dune compiles fine, but VSCode gives a false positive "module missing" using the WSL2 and ocamllsp

Sorry if this is already resolved, but I’ve been sifting through the internet and following tutorials with no results.
Reproducing the issue from zero:
I installed ocaml on the WSL(2) of Windows 11. I don’t understand a lot of the compiling, but I use Dune as a build system, and VSCode as IDE (running on the WSL).
I initialize a project on Ubuntu with: $ dune init proj Test
I open VSCode, and create two files FileA.ml and FileB.ml, with FileB depending on FileA and main.ml being the executable.
main.ml (default generated by Dune):

let () = print_endline "Hello, World!"

FileA.ml:

let testA = true;;

FileB.ml:

let testB = FileA.testA;;

And the dune file contains:

(executable
 (public_name Test)
 (name main)
 (libraries Test))

I can then run $ dune build, which compiles fine (and even $ dune exec Test).
However VSCode indicates the error on FileA.testA:

I can also reinstall OCaml, restart the OCaml Language Server or change the dune file to contain:

(executable
 (public_name Test)
 (name main)
 (libraries Test)
 (modules main FileA FileB))

and it always gives the same error.
Weird thing is that on my original project with a dozen files, this error only appears on some files even when there is nothing special in the dune files.
Thanks for your help.

I’ve been getting false positives for this error for some time now as well. Usually, restarting the VS Code extension host (or the entire window) fixes it for a while, but maybe we ought to open an issue on their tracker.

I’ve also been seeing dune build --watch miss change events, forcing me to restart it; the overall OCaml editing experience is becoming increasingly unstable lately.

Thanks for your input. In my case, restarting anything doesn’t even fixes it temporarily…