Not sure if this is helpful but the error seems to have resolved if I install ppx_deriving version 5.1. So when installing ppx_deriving 5.1, it downgrades the following packages,
↘ downgrade ocaml-migrate-parsetree 2.1.0 to 1.8.0 [required by ppx_deriving]
↘ downgrade ppxlib 0.20.0 to 0.15.0 [required by ppx_deriving]
↘ downgrade ocamlformat 0.16.0 to 0.15.0 [uses ocaml-migrate-parsetree]
↘ downgrade ppx_expect v0.14.1 to v0.14.0 [uses ppxlib]
So I am guessing the issue is in one of the packages above and not dune/ocaml-lsp per se.
I have been unable to fix this by downgrading versions for some time. Both newer versions are broken and the above versions are not working for me. Ocamllsp+vscode is the only place I can replicate this. Dune works just fine.
I’d be happy to spend some to fix, but I am currently stuck debugging what’s going on. 1) The error has no location information or call-stack. 2) Simple print/logging to a file seems to break ocamllsp/vscode as it halts/blocks further progress.