Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unknown error in vscode plugin #374

Open
pszmagaj opened this issue Dec 22, 2019 · 15 comments
Open

Unknown error in vscode plugin #374

pszmagaj opened this issue Dec 22, 2019 · 15 comments

Comments

@pszmagaj
Copy link

pszmagaj commented Dec 22, 2019

Hi,

I have got an unknown error when using vscode plugin.

Plugin version 1.7.4

bs-platform: 5.2.1 but also tried on 7.0.1 with the same effect.

bsconfig.json

{
  "name": "ProjectName",
  "sources": [
    {
      "dir": "src",
      "subdirs": true
    },
    {
      "dir": "__tests__",
      "subdirs": true,
      "type": "dev"
    }
  ],
  "package-specs": {
    "module": "commonjs",
    "in-source": true
  },
  "suffix": ".bs.js",
  "bs-dependencies": [
    "reason-react",
    "@glennsl/bs-json",
    "bs-webapi",
    "bs-fetch",
    "bs-moment",
    "reason-date-fns",
    "re-classnames",
    "reason-apollo",
    "reason-apollo-hooks",
    "re-debouncer",
    "bs-reform",
    "reschema"
  ],
  "bs-dev-dependencies": [
    "@glennsl/bs-jest",
    "bs-react-test-renderer"
  ],
  "ppx-flags": [
    "graphql_ppx/ppx",
    "lenses-ppx/ppx"
  ],
  "reason": {
    "react-jsx": 3
  },
  "refmt": 3,
  "generate-merlin": true,
  "warnings": {
    "number": "-45"
  }
}

The plugin doesn't work. It seems that it cannot compile the code but gets no error. I found in debug log only "type error here " but with no details.

... '/home/pawel/workspace/Leon/client/react/lib/bs/__tests__/src/components/DocumentsManager/List/__snapshots__' -I '/home/pawel/workspace/Leon/client/react/lib/bs/__tests__/src/components/DocumentsManager/Data' -I '/home/pawel/workspace/Leon/client/react/lib/bs/__tests__/src/components/DocumentsManager/Data/__snapshots__' -I '/home/pawel/workspace/Leon/client/react/lib/bs/__tests__/src/components/DocumentsManager/__snapshots__' -I '/home/pawel/workspace/Leon/client/react/node_modules/bs-platform/lib/ocaml' -I '/home/pawel/workspace/Leon/client/react/node_modules/reschema/lib/bs/src' -I '/home/pawel/workspace/Leon/client/react/node_modules/bs-reform/lib/bs' -I '/home/pawel/workspace/Leon/client/react/node_modules/bs-reform/lib/bs/src' -I '/home/pawel/workspace/Leon/client/react/node_modules/re-debouncer/lib/bs/src' -I '/home/pawel/workspace/Leon/client/react/node_modules/reason-apollo-hooks/lib/bs' -I '/home/pawel/workspace/Leon/client/react/node_modules/reason-apollo-hooks/lib/bs/src' -I '/home/pawel/workspace/Leon/client/react/node_modules/reason-apollo/lib/bs/src' -I '/home/pawel/workspace/Leon/client/react/node_modules/reason-apollo/lib/bs/src/graphql-types' -I '/home/pawel/workspace/Leon/client/react/node_modules/re-classnames/lib/bs/src' -I '/home/pawel/workspace/Leon/client/react/node_modules/reason-date-fns/lib/bs' -I '/home/pawel/workspace/Leon/client/react/node_modules/reason-date-fns/lib/bs/src' -I '/home/pawel/workspace/Leon/client/react/node_modules/bs-moment/lib/bs/src' -I '/home/pawel/workspace/Leon/client/react/node_modules/bs-fetch/lib/bs/src' -I '/home/pawel/workspace/Leon/client/react/node_modules/bs-webapi/lib/bs/src' -I '/home/pawel/workspace/Leon/client/react/node_modules/bs-webapi/lib/bs/src/Webapi' -I '/home/pawel/workspace/Leon/client/react/node_modules/bs-webapi/lib/bs/src/Webapi/Webapi__Canvas' -I '/home/pawel/workspace/Leon/client/react/node_modules/bs-webapi/lib/bs/src/Webapi/Webapi__Dom' -I '/home/pawel/workspace/Leon/client/react/node_modules/@glennsl/bs-json/lib/bs/src' -I '/home/pawel/workspace/Leon/client/react/node_modules/reason-react/lib/bs/src' -I '/home/pawel/workspace/Leon/client/react/node_modules/bs-react-test-renderer/lib/bs/src' -I '/home/pawel/workspace/Leon/client/react/node_modules/@glennsl/bs-jest/lib/bs/src' -I '/home/pawel/workspace/Leon/client/react/node_modules/bs-platform/lib/ocaml' -bin-annot -bs-no-builtin-ppx-ml -ppx '/home/pawel/workspace/Leon/client/react/node_modules/graphql_ppx/ppx' -ppx '/home/pawel/workspace/Leon/client/react/node_modules/lenses-ppx/ppx' -ppx '/home/pawel/workspace/Leon/client/react/node_modules/bs-platform/lib/bsppx.exe -bs-jsx 3' -nostdlib -w -30-40+6+7+27+32..39+44+45+101-45 -bs-re-out -impl /home/pawel/workspace/Leon/client/react/node_modules/.lsp/LeonAccountModulesServiceCoder.ast with pwd /home/pawel/workspace/Leon/client/react
type error here

Or something like below (many times for multiple different modules)

<< Making lastDefinitions with type error for file:///home/pawel/workspace/Leon/client/react/__tests__/src/components/Eapis/EapisPersonsTableRow_test.re
type error here 

The project builds and works when compiling by using npx bsb -make-world
Any ideas what it can be?

@jaredly
Copy link
Owner

jaredly commented Dec 30, 2019

@pszmagaj any chance you could make a public example repo so I can investigate?

@pszmagaj
Copy link
Author

@jaredly I cannot share the repo but I can try to create a new project with the same dependencies to reproduce the problem. I may also try to debug the issue by myself but I would need some advice on how it can be done.

@a-gierczak
Copy link

a-gierczak commented Mar 9, 2020

@jaredly @pszmagaj I think I've managed to track down the issue. In our project we have two source directories listed in bsconfig.json.

"sources": [
    {
      "dir": "src",
      "subdirs": true
    },
    {
      "dir": "__tests__",
      "subdirs": true,
      "type": "dev"
    }
  ],

When I remove one of them, the plugin works again. I will try to create minimal reproducible example later.

Edit: After further investigation I've noticed that it's more related to number of directories, not sources. I created empty project with 2 files and 2600 empty directories and RLS stopped working. With 2400 directories it was still doing fine.

@cristianoc
Copy link
Contributor

Similar issue in spirit (integration wit bsb): #414

@IwanKaramazow
Copy link
Contributor

@selenir do you have a repo with that test?

@a-gierczak
Copy link

There it is: https://github.com/selenir/rls-374-repro

@a-gierczak
Copy link

I've managed to reproduce the issue on Windows 10, there are some logs in the "Output" tab, which didn't appear on Linux:
https://gist.github.com/selenir/371e3b357a662e4f737ed4364ac80734

Also while checking logs I've noticed that each directory in project is passed as -I paramter to bsc. Maybe it could be related to max command length in cmd/bash.

@pszmagaj
Copy link
Author

pszmagaj commented Apr 19, 2020

@jaredly Hello. I have investigated a problem and it seems to be linux / ubuntu specific problem. The problem can be recreated using https://github.com/selenir/rls-374-repro. It seems that bsc exits 127 code when run by RLS. The command that RLS uses to compile the project works perfectly when run from command line.

The repro repo causes a problem on Windows and WSL as well however it seems that the cause is different.

[Edit]
I think the problem may be related to MAX_ARG_STRLEN which is 32 * PAGE_SIZE (4KB). When command goes below 128kB it starts working. I do not know how to resolve the problem without recompiling the kernel. Perhaps bsc could take arguments from a file?

@pszmagaj
Copy link
Author

I can see that OCaml compiler has "args" option (http://caml.inria.fr/pub/docs/manual-ocaml/comp.html#s%3Acomp-options). According to https://bucklescript.github.io/docs/en/extended-compiler-options BSC should inherit options from OCAML compiler but I cannot see args option in BSC.

@bobzhang Perhaps you can help us with that? Can BSC expose "-args" OCAML compiler option?

@jazithedev
Copy link

Can some1 fix this in the reason-language-server :)?

@bobzhang
Copy link
Contributor

@pszmagaj Any idea why the command line is that long? 128KB seems a lot

@a-gierczak
Copy link

a-gierczak commented Jul 3, 2020

@bobzhang It's because BSB passes paths of all subdirectories in the project to the compiler. You can easily reach the 128KB mark when you have bigger project.

@pszmagaj
Copy link
Author

pszmagaj commented Jul 3, 2020

@bobzhang I confirm. The project is really big. We have hundreds of Reason and JS modules in a project what makes compiler command very long (~150kB).

@bobzhang
Copy link
Contributor

bobzhang commented Jul 6, 2020

@pszmagaj I guess you meant hundreds of directories?

@pszmagaj
Copy link
Author

pszmagaj commented Jul 6, 2020

@bobzhang Yes. There are hundreds directories.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants