haskell / lsp

Haskell library for the Microsoft Language Server Protocol
360 stars 89 forks source link

lsp-test seems to have a hard time with large files. GHC 9.4, 9.6 linux affected. #497

Open joyfulmantis opened 1 year ago

joyfulmantis commented 1 year ago

This is a weird bug, as it's only triggered on specific GHC and distro versions. Specifically 9.4 and 9.6 with Linux (windows unaffected). I ran into this bug in the HLS CI, and later reproduced it on my own machine. When opening a large file the test will just stop after sending a TextDocumentDidOpen notification, and not even time out. No useful error or debug messages either. The file tested was https://github.com/haskell/haskell-language-server/blob/0271ce212af57dc8ff52e6a80d0ed404cb57853e/plugins/hls-overloaded-record-dot-plugin/test/testdata/Benchmark.hs The logs when the test is terminated with Ctrl+c after around ~50 min are (contents of TextDocumentDidOpen retracted to keep the bug short enough to post)


<no location info>: warning: [-Wunused-packages]
    The following packages were specified via -package or -package-id flags,
    but were not needed for compilation:
      - aeson-pretty-0.8.9 (exposed by flag -package-id aeson-pretty-0.8.9-cc94f32925968947709948654d87925e0922235304fcc388e008f3ecab298408)
      - implicit-hie-0.1.2.7 (exposed by flag -package-id implicit-hie-0.1.2.7-ec013f88f8be03cfe17053bb54b6347a64e275332a18cb0615e9c83d0d7deb49)
2023-06-30T14:51:22.614391Z | Info | Heap statistics are not enabled (RTS option -T is needed)
2023-06-30T14:51:22.615094Z | Info | Starting LSP server...
  If you are seeing this in a terminal, you probably should have run WITHOUT the --lsp option!
  PluginIds: [ overloaded-record-dot
             , test
             , ghcide-completions
             , block-command
             , ghcide-hover-and-symbols
             , ghcide-type-lenses
             , ghcide-core ]
2023-06-30T14:51:22.615483Z | Info | Starting server
2023-06-30T14:51:22.624101Z | Info | Started LSP server in 0.01s
2023-06-30T14:51:22.630441Z | Debug | executing command: cabal exec -v0 -- ghc --print-libdir
2023-06-30T14:51:24.150102Z | Debug | executing command: cabal exec -v0 -- ghc -package-env=- -ignore-dot-ghci -e Control.Monad.join (Control.Monad.fmap System.IO.putStr System.Environment.getExecutablePath)
2023-06-30T14:51:25.142728Z | Debug | executing command: cabal --builddir=/home/zhangtianci/.cache/hie-bios/dist-haskell-language-server-d168a6a0bd3fe20ed93b29bb35ffd16e v2-exec --with-compiler /home/zhangtianci/.cache/hie-bios/wrapper-b54f81dea4c0e6d1626911c526bc4e36 --with-hc-pkg /home/zhangtianci/.cache/hie-bios/ghc-pkg-018ac07ec696acc23a6bacd0dc34d144 ghc -v0 -- --print-libdir
2023-06-30T14:51:26.634745Z | Debug | Setting initial dynflags...
2023-06-30T14:51:26.634879Z | Debug | shouldRunSubset: True
2023-06-30T14:51:26.635007Z | Debug | Initializing exports map from hiedb
2023-06-30T14:51:26.635327Z | Info | Registering IDE configuration: IdeConfiguration {workspaceFolders = fromList [NormalizedUri (-2424510451474401224) "file:///home/zhangtianci/MySourceCode/haskell-language-server/plugins/hls-overloaded-record-dot-plugin/test/testdata"], clientSettings = hashed Nothing}
^C2023-06-30T15:37:31.072886Z | Debug | Done initializing exports map from hiedb. Size: 1
2023-06-30T15:37:31.074712Z | Debug | Shake session initialized
2023-06-30T15:37:31.080661Z | Debug | Received shutdown message
2023-06-30T15:37:31.083103Z | Debug | Set files of interest to: fromList [(NormalizedFilePath "/home/zhangtianci/MySourceCode/haskell-language-server/plugins/hls-overloaded-record-dot-plugin/test/testdata/Benchmark.hs",Modified {firstOpen = True})]
2023-06-30T15:37:31.088110Z | Info | Reactor thread stopped
2023-06-30T15:37:31.088255Z | Debug | Finished build session
AsyncCancelled

and

Running 1 test suites...
Test suite tests: RUNNING...
overloaded-record-dot
  Benchmark without resolve: --> {
    "id": 0,
    "jsonrpc": "2.0",
    "method": "initialize",
    "params": {
        "capabilities": {
            "general": {
                "markdown": {
                    "allowedTags": [],
                    "parser": ""
                },
                "regularExpressions": {
                    "engine": ""
                },
                "staleRequestSupport": {
                    "cancel": true,
                    "retryOnContentModified": []
                }
            },
            "textDocument": {
                "callHierarchy": {
                    "dynamicRegistration": true
                },
                "codeAction": {
                    "codeActionLiteralSupport": {
                        "codeActionKind": {
                            "valueSet": [
                                "",
                                "quickfix",
                                "refactor",
                                "refactor.extract",
                                "refactor.inline",
                                "refactor.rewrite",
                                "source",
                                "source.organizeImports",
                                "source.fixAll"
                            ]
                        }
                    },
                    "dataSupport": false,
                    "disabledSupport": true,
                    "dynamicRegistration": true,
                    "honorsChangeAnnotations": true,
                    "isPreferredSupport": true
                },
                "codeLens": {
                    "dynamicRegistration": true
                },
                "colorProvider": {
                    "dynamicRegistration": true
                },
                "completion": {
                    "completionItem": {
                        "commitCharactersSupport": true,
                        "deprecatedSupport": true,
                        "documentationFormat": [
                            "plaintext",
                            "markdown"
                        ],
                        "insertReplaceSupport": true,
                        "insertTextModeSupport": {
                            "valueSet": []
                        },
                        "labelDetailsSupport": true,
                        "preselectSupport": true,
                        "resolveSupport": {
                            "properties": [
                                "documentation",
                                "details"
                            ]
                        },
                        "snippetSupport": true,
                        "tagSupport": {
                            "valueSet": []
                        }
                    },
                    "completionItemKind": {
                        "valueSet": [
                            1,
                            2,
                            3,
                            4,
                            5,
                            6,
                            7,
                            8,
                            9,
                            10,
                            11,
                            12,
                            13,
                            14,
                            15,
                            16,
                            17,
                            18,
                            19,
                            20,
                            21,
                            22,
                            23,
                            24,
                            25
                        ]
                    },
                    "completionList": {
                        "itemDefaults": []
                    },
                    "contextSupport": true,
                    "dynamicRegistration": true,
                    "insertTextMode": 1
                },
                "declaration": {
                    "dynamicRegistration": true,
                    "linkSupport": true
                },
                "definition": {
                    "dynamicRegistration": true,
                    "linkSupport": true
                },
                "documentHighlight": {
                    "dynamicRegistration": true
                },
                "documentLink": {
                    "dynamicRegistration": true,
                    "tooltipSupport": true
                },
                "documentSymbol": {
                    "dynamicRegistration": true,
                    "hierarchicalDocumentSymbolSupport": true,
                    "labelSupport": true,
                    "symbolKind": {
                        "valueSet": [
                            1,
                            2,
                            3,
                            4,
                            5,
                            6,
                            7,
                            8,
                            9,
                            10,
                            11,
                            12,
                            13,
                            14,
                            15,
                            16,
                            17,
                            18,
                            19,
                            20,
                            21,
                            22,
                            23,
                            24,
                            25,
                            26
                        ]
                    },
                    "tagSupport": {
                        "valueSet": [
                            1
                        ]
                    }
                },
                "foldingRange": {
                    "dynamicRegistration": true,
                    "foldingRange": {
                        "collapsedText": true
                    },
                    "foldingRangeKind": {
                        "valueSet": []
                    }
                },
                "formatting": {
                    "dynamicRegistration": true
                },
                "hover": {
                    "contentFormat": [
                        "plaintext",
                        "markdown"
                    ],
                    "dynamicRegistration": true
                },
                "implementation": {
                    "dynamicRegistration": true,
                    "linkSupport": true
                },
                "onTypeFormatting": {
                    "dynamicRegistration": true
                },
                "publishDiagnostics": {
                    "codeDescriptionSupport": true,
                    "dataSupport": true,
                    "relatedInformation": true,
                    "tagSupport": {
                        "valueSet": [
                            1,
                            2
                        ]
                    },
                    "versionSupport": true
                },
                "rangeFormatting": {
                    "dynamicRegistration": true
                },
                "references": {
                    "dynamicRegistration": true
                },
                "rename": {
                    "dynamicRegistration": true,
                    "honorsChangeAnnotations": true,
                    "prepareSupport": true,
                    "prepareSupportDefaultBehavior": 1
                },
                "selectionRange": {
                    "dynamicRegistration": true
                },
                "semanticTokens": {
                    "augmentsSyntaxTokens": true,
                    "dynamicRegistration": true,
                    "formats": [
                        "relative"
                    ],
                    "multilineTokenSupport": true,
                    "overlappingTokenSupport": true,
                    "requests": {
                        "full": {
                            "delta": true
                        },
                        "range": true
                    },
                    "serverCancelSupport": true,
                    "tokenModifiers": [
                        "declaration",
                        "definition",
                        "readonly",
                        "static",
                        "deprecated",
                        "abstract",
                        "async",
                        "modification",
                        "documentation",
                        "defaultLibrary"
                    ],
                    "tokenTypes": [
                        "namespace",
                        "type",
                        "class",
                        "enum",
                        "interface",
                        "struct",
                        "typeParameter",
                        "parameter",
                        "variable",
                        "property",
                        "enumMember",
                        "event",
                        "function",
                        "method",
                        "macro",
                        "keyword",
                        "modifier",
                        "comment",
                        "string",
                        "number",
                        "regexp",
                        "operator",
                        "decorator"
                    ]
                },
                "signatureHelp": {
                    "contextSupport": true,
                    "dynamicRegistration": true,
                    "signatureInformation": {
                        "activeParameterSupport": true,
                        "documentationFormat": [
                            "plaintext",
                            "markdown"
                        ],
                        "parameterInformation": {
                            "labelOffsetSupport": true
                        }
                    }
                },
                "synchronization": {
                    "didSave": true,
                    "dynamicRegistration": true,
                    "willSave": true,
                    "willSaveWaitUntil": true
                },
                "typeDefinition": {
                    "dynamicRegistration": true,
                    "linkSupport": true
                }
            },
            "window": {
                "showDocument": {
                    "support": true
                },
                "showMessage": {},
                "workDoneProgress": true
            },
            "workspace": {
                "applyEdit": true,
                "configuration": true,
                "didChangeConfiguration": {
                    "dynamicRegistration": true
                },
                "didChangeWatchedFiles": {
                    "dynamicRegistration": true,
                    "relativePatternSupport": true
                },
                "executeCommand": {
                    "dynamicRegistration": true
                },
                "semanticTokens": {
                    "refreshSupport": true
                },
                "symbol": {
                    "dynamicRegistration": true,
                    "resolveSupport": {
                        "properties": []
                    },
                    "symbolKind": {
                        "valueSet": [
                            1,
                            2,
                            3,
                            4,
                            5,
                            6,
                            7,
                            8,
                            9,
                            10,
                            11,
                            12,
                            13,
                            14,
                            15,
                            16,
                            17,
                            18,
                            19,
                            20,
                            21,
                            22,
                            23,
                            24,
                            25,
                            26
                        ]
                    },
                    "tagSupport": {
                        "valueSet": [
                            1
                        ]
                    }
                },
                "workspaceEdit": {
                    "changeAnnotationSupport": {
                        "groupsOnLabel": true
                    },
                    "documentChanges": true,
                    "normalizesLineEndings": true,
                    "resourceOperations": [
                        "create",
                        "delete",
                        "rename"
                    ]
                },
                "workspaceFolders": true
            }
        },
        "clientInfo": {
            "name": "lsp-test",
            "version": "0.15.0.0"
        },
        "locale": "/home/zhangtianci/MySourceCode/haskell-language-server/plugins/hls-overloaded-record-dot-plugin/test/testdata",
        "processId": 411225,
        "rootUri": "file:///home/zhangtianci/MySourceCode/haskell-language-server/plugins/hls-overloaded-record-dot-plugin/test/testdata",
        "trace": "off"
    }
}
<-- {
    "id": 0,
    "jsonrpc": "2.0",
    "result": {
        "capabilities": {
            "callHierarchyProvider": false,
            "codeActionProvider": {
                "resolveProvider": true
            },
            "codeLensProvider": {
                "resolveProvider": false,
                "workDoneProgress": false
            },
            "colorProvider": false,
            "completionProvider": {
                "resolveProvider": true,
                "triggerCharacters": [
                    "."
                ]
            },
            "declarationProvider": false,
            "definitionProvider": true,
            "documentFormattingProvider": false,
            "documentHighlightProvider": true,
            "documentRangeFormattingProvider": false,
            "documentSymbolProvider": true,
            "executeCommandProvider": {
                "commands": [
                    "411225:block-command:ghcide.command.block",
                    "411225:ghcide-type-lenses:typesignature.add"
                ]
            },
            "foldingRangeProvider": false,
            "hoverProvider": true,
            "implementationProvider": false,
            "referencesProvider": true,
            "renameProvider": false,
            "selectionRangeProvider": false,
            "semanticTokensProvider": {
                "legend": {
                    "tokenModifiers": [
                        "declaration",
                        "definition",
                        "readonly",
                        "static",
                        "deprecated",
                        "abstract",
                        "async",
                        "modification",
                        "documentation",
                        "defaultLibrary"
                    ],
                    "tokenTypes": [
                        "namespace",
                        "type",
                        "class",
                        "enum",
                        "interface",
                        "struct",
                        "typeParameter",
                        "parameter",
                        "variable",
                        "property",
                        "enumMember",
                        "event",
                        "function",
                        "method",
                        "macro",
                        "keyword",
                        "modifier",
                        "comment",
                        "string",
                        "number",
                        "regexp",
                        "operator",
                        "decorator"
                    ]
                }
            },
            "textDocumentSync": {
                "change": 2,
                "openClose": true,
                "save": {}
            },
            "typeDefinitionProvider": true,
            "workspace": {
                "workspaceFolders": {
                    "changeNotifications": true,
                    "supported": true
                }
            },
            "workspaceSymbolProvider": true
        }
    }
}
--> {
    "jsonrpc": "2.0",
    "method": "initialized",
    "params": {}
}
--> {
    "jsonrpc": "2.0",
    "method": "textDocument/didOpen",
    "params": {
        "textDocument": {
            "languageId": "haskell",
            "text": "[retracted to keep issue length under the maximum of 65536 characters]",
            "uri": "file:///home/zhangtianci/MySourceCode/haskell-language-server/plugins/hls-overloaded-record-dot-plugin/test/testdata/Benchmark.hs",
            "version": 0
        }
    }
}
--> {
    "id": 1,
    "jsonrpc": "2.0",
    "method": "test",
    "params": {
        "tag": "WaitForShakeQueue"
    }
}
--> {
    "id": 0,
    "jsonrpc": "2.0",
    "method": "shutdown",
    "params": null
}
<-- {
    "jsonrpc": "2.0",
    "method": "kick/start",
    "params": []
}
--> {
    "id": 0,
    "jsonrpc": "2.0",
    "result": null
}
<-- {
    "id": 0,
    "jsonrpc": "2.0",
    "method": "window/workDoneProgress/create",
    "params": {
        "token": "4"
    }
}
<-- {
    "id": 1,
    "jsonrpc": "2.0",
    "method": "client/registerCapability",
    "params": {
        "registrations": [
            {
                "id": "globalFileWatches",
                "method": "workspace/didChangeWatchedFiles",
                "registerOptions": {
                    "watchers": [
                        {
                            "globPattern": "**/*.hs",
                            "kind": 7
                        },
                        {
                            "globPattern": "**/*.hs-boot",
                            "kind": 7
                        },
                        {
                            "globPattern": "**/*.lhs",
                            "kind": 7
                        },
                        {
                            "globPattern": "**/*.lhs-boot",
                            "kind": 7
                        }
                    ]
                }
            }
        ]
    }
}
<-- {
    "jsonrpc": "2.0",
    "method": "kick/done",
    "params": []
}
<-- {
    "id": 0,
    "jsonrpc": "2.0",
    "result": null
}
--> {
    "jsonrpc": "2.0",
    "method": "exit",
    "params": null
}