semgrep / semgrep-vscode

Semgrep extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=semgrep.semgrep
GNU Lesser General Public License v2.1
53 stars 24 forks source link

Extension crashing multiple times for unknown reason #142

Open skeymeulen opened 4 months ago

skeymeulen commented 4 months ago

Extension crashes multiple times when specific files are open in VSCode for unknown reasons in JS mode.

VSCode outputs:

The Semgrep server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.

Extension version: v1.7.1

Expected behaviour: Extension should not crash, or at least log clearly why it crashed. Current Behavior: Extension crashes multiple times for unknown reasons.

How to reproduce I have created a public repo containing an example file that can be used to reproduce this issue. https://github.com/skeymeulen/semgrep-crash-example-repo

I'm running the VSCode plugin on a MacBook in JS mode and Only Git Dirty disabled. When opening the index.js file in the example repo above, the integration start crashing, restarting and crashing again until VSCode stops restarting the server with the following message 'The Semgrep server crashed 5 times in the last 3 minutes. The server will not be restarted.'

The Semgrep logs in the VSCode output are always the same before the crash.

[Trace - 16:45:53] Received notification '$/progress'.
Params: {
    "token": "9d092828-8886-4ff2-ae5a-bb766f6eab6b",
    "value": {
        "kind": "begin",
        "message": "Refreshing Rules",
        "title": "Semgrep"
    }
}

/Users/myuser/.vscode/extensions/semgrep.semgrep-1.7.1/lspjs/dist/Main.bc.js:1947
throw err}function
^

[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "[object Array]".] {
  code: 'ERR_UNHANDLED_REJECTION'
}
ajbt200128 commented 4 months ago

Going to look into this. Just wondering, why are you using JS mode on MacOS? Using the semgrep CLI instead of js mode will be way more performant and stable

skeymeulen commented 3 months ago

I'm working on MacOS, so its easier for me to reproduce these issues on Mac. But a lot of my colleagues are on Windows, would be nice to have comparable experience on Windows.

ajbt200128 commented 3 months ago

ahh got it. The new version of the extension that should release sometime today (1.8.2) has improved error messaging when it comes to JS, and I fixed a few things up there too. Could you try the newest version and see if there's any improved error messaging?