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

How to debug Flow? #5

Closed
villesau opened this issue Nov 6, 2018 · 5 comments
Closed

How to debug Flow? #5

villesau opened this issue Nov 6, 2018 · 5 comments

Comments

@villesau
Copy link

villesau commented Nov 6, 2018

Flow has issue of debugging, and people has succeeded to debug it with certain configurations: facebook/flow#4181

Anyhow, with vscode-ocaml-debugger I have not been able to start debug session with flow. Looks like nothing happens with following config, just endless blue loading bar appears and thats it:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "OCaml",
            "type": "ocaml-debugger",
            "request": "launch",
            "program": "${workspaceFolder}/bin/flow",
            "console": "internalConsole",
            "stopOnEntry": false,
            "arguments": ["check", "${workspaceFolder}/my-own-test/test.js", "--max-workers", "0"]
          }
    ]
}

Would be nice to see some logging if there is e.g something that goes wrong.

@hackwaly
Copy link
Owner

hackwaly commented Nov 7, 2018

I have not enough time to address your issue. You can use ocaml-debugger to debug ocaml-debugger to debug flow to check out what happens.

First you need clone [email protected]:hackwaly/ocamlearlybird.git, Use vscode open the project folder. Then use this configuration to debug ocamlearlybird.

    {
      "name": "Debugger",
      "type": "ocaml-debugger",
      "request": "launch",
      "program": "${workspaceRoot}/_build/default/ocaml_debug_adapter/main.bc",
      "arguments": ["--server", "--port=4712"],
      "preLaunchTask": "build",
      "console": "internalConsole",
      "env": {
        "OCAMLRUNPARAM": "b"
      }
    },

Then use the debugged ocamlearlybird to debug flow:

        {
            "name": "OCaml",
            "type": "ocaml-debugger",
            "request": "launch",
            "program": "${workspaceFolder}/bin/flow",
            "console": "internalConsole",
            "stopOnEntry": false,
            "arguments": ["check", "${workspaceFolder}/my-own-test/test.js", "--max-workers", "0"],
            "debugServer": 4712
          }

@villesau
Copy link
Author

villesau commented Dec 11, 2018

Hi @hackwaly,

In sessiom.ml
Initialize_command gets following args:
screenshot 2018-12-11 at 20 48 53

and Launch_command gets following args:

screenshot 2018-12-11 at 20 52 08

Also noticed that the program is apparently launched with ocamlrun command? Something like: ocamlrun bin/flow check my-own-test/test.js --max-workers 0 but when running that manually I'm getting:

Fatal error: unknown C primitive `unix_waitpid'

Maybe this is the culprit? Taking the ocamlrun off runs the program fine. I'm trying to debug on macOS.

E: When downgrading Ocaml from 4.06.0 to 4.05.0, the error changes to:

Fatal error: unknown C primitive `caml_floatarray_create'

@hackwaly
Copy link
Owner

Looks like this issue ocaml-community/utop#34

@hackwaly
Copy link
Owner

@villesau This should be fixed as I removed the unnecessary ocamlrun.
Track progress ocaml/opam-repository#13149

@villesau
Copy link
Author

@hackwaly Nice, thanks! Works like a charm now!

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

No branches or pull requests

2 participants