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

x/tools/gopls: empty diagnostics overwrites earlier diagnostics with same version #42837

Closed
leitzler opened this issue Nov 25, 2020 · 4 comments
Closed

Comments

@leitzler
Copy link
Contributor

@leitzler leitzler commented Nov 25, 2020

What version of Go are you using (go version)?

$ go version
go1.15.2
$ go list -m golang.org/x/tools golang.org/x/tools/gopls
golang.org/x/tools v0.0.0-20201124202034-299f270db459
golang.org/x/tools/gopls v0.0.0-20201124202034-299f270db459

What did you do?

This was found during govim CI tests with race-detection enabled where several different test cases failed, https://github.com/govim/govim/actions/runs/382858463.

I looked at two different failures and the common thing was that gopls did send publishDiagnostics without any diagnostics after sending real diagnostics.

e.g. this log where "version": 5 is sent twice, empty the second time:

[Trace - 22:47:42.009 PM] Sending request 'initialize - (1)'.
Params: {"processId":0,"clientInfo":{"name":""},"rootUri":"file:///artefacts/govim/cmd/govim-race/scenario_default/script-gofmt","capabilities":{"Workspace":{"workspaceEdit":{},"didChangeConfiguration":{"dynamicRegistration":true},"didChangeWatchedFiles":{"dynamicRegistration":true},"symbol":{"symbolKind":{},"tagSupport":{"valueSet":null}},"executeCommand":{},"semanticTokens":{},"configuration":true},"textDocument":{"synchronization":{},"completion":{"completionItem":{"tagSupport":{"valueSet":null},"resolveSupport":{"properties":null}},"completionItemKind":{}},"hover":{"contentFormat":["plaintext"]},"signatureHelp":{"signatureInformation":{"parameterInformation":{}}},"declaration":{},"definition":{},"typeDefinition":{},"implementation":{},"references":{},"documentHighlight":{},"documentSymbol":{"symbolKind":{},"tagSupport":{"valueSet":null}},"codeAction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":null}},"resolveSupport":{"properties":null}},"codeLens":{},"documentLink":{},"colorProvider":{},"formatting":{},"rangeFormatting":{},"onTypeFormatting":{},"rename":{},"foldingRange":{},"selectionRange":{},"publishDiagnostics":{"tagSupport":{"valueSet":null}},"callHierarchy":{},"semanticTokens":{"requests":{},"tokenTypes":null,"tokenModifiers":null,"formats":null}},"Window":{"workDoneProgress":true}},"initializationOptions":{"symbolMatcher":"fuzzy","symbolStyle":"full"},"workspaceFolders":null}

[Trace - 22:47:42.014 PM] Received response 'initialize - (1)' in 5ms.
Result: {"capabilities":{"textDocumentSync":{"openClose":true,"change":2,"save":{}},"completionProvider":{"triggerCharacters":["."]},"hoverProvider":true,"signatureHelpProvider":{"triggerCharacters":["(",","]},"definitionProvider":true,"typeDefinitionProvider":true,"implementationProvider":true,"referencesProvider":true,"documentHighlightProvider":true,"documentSymbolProvider":true,"codeActionProvider":true,"codeLensProvider":{},"documentLinkProvider":{},"workspaceSymbolProvider":true,"documentFormattingProvider":true,"documentOnTypeFormattingProvider":{"firstTriggerCharacter":""},"renameProvider":true,"foldingRangeProvider":true,"executeCommandProvider":{"commands":["gopls.generate","gopls.fill_struct","gopls.regenerate_cgo","gopls.test","gopls.tidy","gopls.undeclared_name","gopls.add_dependency","gopls.upgrade_dependency","gopls.remove_dependency","gopls.vendor","gopls.extract_variable","gopls.extract_function","gopls.gc_details","gopls.generate_gopls_mod"]},"callHierarchyProvider":true,"workspace":{"workspaceFolders":{"supported":true,"changeNotifications":"workspace/didChangeWorkspaceFolders"}}},"serverInfo":{"name":"gopls","version":"{"path":"golang.org/x/tools/gopls","version":"v0.0.0-20201124202034-299f270db459","sum":"h1:nmlDEuxI9XQoUpls13E56e3+7RzC8jHtyrHi06sCbDk=","deps":[{"path":"github.com/BurntSushi/toml","version":"v0.3.1","sum":"h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ="},{"path":"github.com/google/go-cmp","version":"v0.5.1","sum":"h1:JFrFEBb2xKufg6XkJsJr+WbKb4FQlURi5RUcBveYu9k="},{"path":"github.com/sergi/go-diff","version":"v1.1.0","sum":"h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0="},{"path":"golang.org/x/mod","version":"v0.3.0","sum":"h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4="},{"path":"golang.org/x/sync","version":"v0.0.0-20201020160332-67f06af15bc9","sum":"h1:SQFwaSi55rU7vdNs9Yr0Z324VNlrF+0wMqRXT4St8ck="},{"path":"golang.org/x/tools","version":"v0.0.0-20201124202034-299f270db459","sum":"h1:XrUnpqJ8xqeZHrgPu3FuYCv9/O3MrxnIKh5/+MLDE8Q="},{"path":"golang.org/x/xerrors","version":"v0.0.0-20200804184101-5ec99f83aff1","sum":"h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE="},{"path":"honnef.co/go/tools","version":"v0.0.1-2020.1.6","sum":"h1:W18jzjh8mfPez+AwGLxmOImucz/IFjpNlrKVnaj2YVc="},{"path":"mvdan.cc/gofumpt","version":"v0.0.0-20200927160801-5bfeb2e70dd6","sum":"h1:z+/YqapuV7VZPvBb3GYmuEJbA88M3PFUxaHilHYVCpQ="},{"path":"mvdan.cc/xurls/v2","version":"v2.2.0","sum":"h1:NSZPykBXJFCetGZykLAxaL6SIpvbVy/UFEniIfHAa8A="}]}"}}

[Trace - 22:47:42.024 PM] Sending notification 'initialized'.
Params: {}

[Trace - 22:47:42.025 PM] Received request 'window/workDoneProgress/create - (1)'.
Params: {"token":"5577006791947779410"}

[Trace - 22:47:42.034 PM] Sending response 'window/workDoneProgress/create - (1)' in 9ms.
Result:

[Trace - 22:47:42.035 PM] Received notification '$/progress'.
Params: {"token":"5577006791947779410","value":{"kind":"begin","title":"Setting up workspace","message":"Loading packages..."}}

[Trace - 22:47:42.036 PM] Received request 'workspace/configuration - (2)'.
Params: {"items":[{"scopeUri":"file:///artefacts/govim/cmd/govim-race/scenario_default/script-gofmt","section":"gopls"}]}

[Trace - 22:47:42.053 PM] Sending response 'workspace/configuration - (2)' in 16ms.
Result: [{"analyses":{},"codelens":{"gc_details":true},"completionBudget":"0ms","hoverKind":"FullDocumentation","staticcheck":false,"tempModfile":false,"verboseOutput":true}]

[Trace - 22:47:42.066 PM] Sending notification 'textDocument/didOpen'.
Params: {"textDocument":{"uri":"file:///artefacts/govim/cmd/govim-race/scenario_default/script-gofmt/file.go","languageId":"go","version":1,"text":"package blah\n\nconst ( x = 5\ny = x\n )\n\n"}}

[Trace - 22:47:42.110 PM] Sending request 'textDocument/formatting - (2)'.
Params: {"textDocument":{"uri":"file:///artefacts/govim/cmd/govim-race/scenario_default/script-gofmt/file.go"},"options":{"tabSize":0,"insertSpaces":false}}

[Trace - 22:47:42.272 PM] Received request 'client/registerCapability - (3)'.
Params: {"registrations":[{"id":"workspace/didChangeWatchedFiles-0","method":"workspace/didChangeWatchedFiles","registerOptions":{"watchers":[{"globPattern":"**/*.{go,mod,sum}","kind":7}]}}]}

[Trace - 22:47:42.273 PM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2020/11/24 22:47:42 go env for /artefacts/govim/cmd/govim-race/scenario_default/script-gofmt\n(root /artefacts/govim/cmd/govim-race/scenario_default/script-gofmt)\n(go version go version go1.15.2 linux/amd64)\n(valid build configuration = true)\n(build flags: [])\nGONOPROXY=\nGONOSUMDB=*\nGOSUMDB=sum.golang.org\nGOCACHE=/home/runner/.cache/go-build\nGOINSECURE=\nGOMODCACHE=/artefacts/govim/cmd/govim-race/scenario_default/script-gofmt/.home/gopath/pkg/mod\nGOPROXY=http://127.0.0.1:41981/mod\nGOFLAGS=\nGOROOT=/go\nGO111MODULE=\nGOPRIVATE=\nGOMOD=/artefacts/govim/cmd/govim-race/scenario_default/script-gofmt/go.mod\nGOPATH=/artefacts/govim/cmd/govim-race/scenario_default/script-gofmt/.home/gopath\n\n"}

[Trace - 22:47:42.277 PM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2020/11/24 22:47:42 12.596301ms for GOROOT=/go GOPATH=/artefacts/govim/cmd/govim-race/scenario_default/script-gofmt/.home/gopath GO111MODULE=off GOPROXY=http://127.0.0.1:41981/mod PWD=/artefacts/govim/cmd/govim-race/scenario_default/script-gofmt go list -e -f {{context.ReleaseTags}}\n"}

[Trace - 22:47:42.277 PM] Sending response 'client/registerCapability - (3)' in 4ms.
Result:

[Trace - 22:47:42.277 PM] Received request 'client/registerCapability - (4)'.
Params: {"registrations":[{"id":"workspace/didChangeConfiguration","method":"workspace/didChangeConfiguration"},{"id":"workspace/didChangeWorkspaceFolders","method":"workspace/didChangeWorkspaceFolders"}]}

[Trace - 22:47:42.294 PM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2020/11/24 22:47:42 29.622972ms for GOROOT=/go GOPATH=/artefacts/govim/cmd/govim-race/scenario_default/script-gofmt/.home/gopath GO111MODULE= GOPROXY=http://127.0.0.1:41981/mod PWD=/artefacts/govim/cmd/govim-race/scenario_default/script-gofmt go list -f "{{context.GOARCH}} {{context.Compiler}}" -- unsafe\n"}

[Trace - 22:47:42.295 PM] Sending response 'client/registerCapability - (4)' in 17ms.
Result:

[Trace - 22:47:42.304 PM] Received notification '$/progress'.
Params: {"token":"5577006791947779410","value":{"kind":"end","message":"Finished loading packages."}}

[Trace - 22:47:42.314 PM] Received response 'textDocument/formatting - (2)' in 203ms.
Result: [{"range":{"start":{"line":2,"character":7},"end":{"line":2,"character":8}},"newText":""},{"range":{"start":{"line":2,"character":8},"end":{"line":2,"character":8}},"newText":"\n\t"},{"range":{"start":{"line":3,"character":0},"end":{"line":3,"character":0}},"newText":"\t"},{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":1}},"newText":""},{"range":{"start":{"line":5,"character":0},"end":{"line":6,"character":0}},"newText":""}]

[Trace - 22:47:42.315 PM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2020/11/24 22:47:42 24.632992ms for GOROOT=/go GOPATH=/artefacts/govim/cmd/govim-race/scenario_default/script-gofmt/.home/gopath GO111MODULE= GOPROXY=http://127.0.0.1:41981/mod PWD=/artefacts/govim/cmd/govim-race/scenario_default/script-gofmt go list -e -json -compiled=true -test=true -export=false -deps=true -find=false -- builtin mod.com/...\n"}

[Trace - 22:47:42.316 PM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2020/11/24 22:47:42 go/packages.Load\n\tsnapshot=0\n\tdirectory=/artefacts/govim/cmd/govim-race/scenario_default/script-gofmt\n\tquery=[builtin mod.com/...]\n\tpackages=2\n"}

[Trace - 22:47:42.316 PM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2020/11/24 22:47:42 go/packages.Load\n\tsnapshot=0\n\tpackage_path="builtin"\n\tfiles=[/go/src/builtin/builtin.go]\n"}

[Trace - 22:47:42.316 PM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2020/11/24 22:47:42 go/packages.Load\n\tsnapshot=0\n\tpackage_path="mod.com"\n\tfiles=[/artefacts/govim/cmd/govim-race/scenario_default/script-gofmt/file.go]\n"}

[Trace - 22:47:42.323 PM] Sending notification 'textDocument/didChange'.
Params: {"textDocument":{"version":2,"uri":"file:///artefacts/govim/cmd/govim-race/scenario_default/script-gofmt/file.go"},"contentChanges":[{"text":"package blah\n\nconst (\n\tx = 5\n\ty = x\n)\n"}]}

[Trace - 22:47:42.410 PM] Sending notification 'workspace/didChangeWatchedFiles'.
Params: {"changes":[{"uri":"file:///artefacts/govim/cmd/govim-race/scenario_default/script-gofmt/file.go","type":2}]}

[Trace - 22:47:42.411 PM] Sending notification 'workspace/didChangeWatchedFiles'.
Params: {"changes":[{"uri":"file:///artefacts/govim/cmd/govim-race/scenario_default/script-gofmt/file.go","type":2}]}

[Trace - 22:47:42.415 PM] Sending notification 'workspace/didChangeWatchedFiles'.
Params: {"changes":[{"uri":"file:///artefacts/govim/cmd/govim-race/scenario_default/script-gofmt/file.go","type":2}]}

[Trace - 22:47:42.429 PM] Sending notification 'workspace/didChangeWatchedFiles'.
Params: {"changes":[{"uri":"file:///artefacts/govim/cmd/govim-race/scenario_default/script-gofmt/file.go","type":2}]}

[Trace - 22:47:42.430 PM] Sending notification 'workspace/didChangeWatchedFiles'.
Params: {"changes":[{"uri":"file:///artefacts/govim/cmd/govim-race/scenario_default/script-gofmt/file.go","type":2}]}

[Trace - 22:47:42.457 PM] Sending notification 'workspace/didChangeConfiguration'.
Params: {"settings":null}

[Trace - 22:47:42.458 PM] Received request 'workspace/configuration - (5)'.
Params: {"items":[{"section":"gopls"}]}

[Trace - 22:47:42.461 PM] Sending response 'workspace/configuration - (5)' in 2ms.
Result: [{"analyses":{},"codelens":{"gc_details":true},"completionBudget":"0ms","hoverKind":"FullDocumentation","staticcheck":false,"tempModfile":false,"verboseOutput":true}]

[Trace - 22:47:42.461 PM] Received request 'workspace/configuration - (6)'.
Params: {"items":[{"scopeUri":"file:///artefacts/govim/cmd/govim-race/scenario_default/script-gofmt","section":"gopls"}]}

[Trace - 22:47:42.464 PM] Sending response 'workspace/configuration - (6)' in 2ms.
Result: [{"analyses":{},"codelens":{"gc_details":true},"completionBudget":"0ms","hoverKind":"FullDocumentation","staticcheck":false,"tempModfile":false,"verboseOutput":true}]

[Trace - 22:47:42.501 PM] Sending notification 'textDocument/didChange'.
Params: {"textDocument":{"version":3,"uri":"file:///artefacts/govim/cmd/govim-race/scenario_default/script-gofmt/file.go"},"contentChanges":[{"text":"package blah\n\nconst ( x = 5\ny = x\n )\n\n"}]}

[Trace - 22:47:42.594 PM] Sending request 'textDocument/formatting - (3)'.
Params: {"textDocument":{"uri":"file:///artefacts/govim/cmd/govim-race/scenario_default/script-gofmt/file.go"},"options":{"tabSize":0,"insertSpaces":false}}

[Trace - 22:47:42.596 PM] Received response 'textDocument/formatting - (3)' in 2ms.
Result: [{"range":{"start":{"line":2,"character":7},"end":{"line":2,"character":8}},"newText":""},{"range":{"start":{"line":2,"character":8},"end":{"line":2,"character":8}},"newText":"\n\t"},{"range":{"start":{"line":3,"character":0},"end":{"line":3,"character":0}},"newText":"\t"},{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":1}},"newText":""},{"range":{"start":{"line":5,"character":0},"end":{"line":6,"character":0}},"newText":""}]

[Trace - 22:47:42.605 PM] Sending notification 'textDocument/didChange'.
Params: {"textDocument":{"version":4,"uri":"file:///artefacts/govim/cmd/govim-race/scenario_default/script-gofmt/file.go"},"contentChanges":[{"text":"package blah\n\nconst (\n\tx = 5\n\ty = x\n)\n"}]}

[Trace - 22:47:42.610 PM] Sending notification 'workspace/didChangeWatchedFiles'.
Params: {"changes":[{"uri":"file:///artefacts/govim/cmd/govim-race/scenario_default/script-gofmt/file.go","type":2}]}

[Trace - 22:47:42.616 PM] Sending notification 'workspace/didChangeWatchedFiles'.
Params: {"changes":[{"uri":"file:///artefacts/govim/cmd/govim-race/scenario_default/script-gofmt/file.go","type":2}]}

[Trace - 22:47:42.617 PM] Sending notification 'textDocument/didSave'.
Params: {"textDocument":{"version":4,"uri":"file:///artefacts/govim/cmd/govim-race/scenario_default/script-gofmt/file.go"}}

[Trace - 22:47:42.636 PM] Sending notification 'workspace/didChangeWatchedFiles'.
Params: {"changes":[{"uri":"file:///artefacts/govim/cmd/govim-race/scenario_default/script-gofmt/file.go","type":2}]}

[Trace - 22:47:42.637 PM] Sending notification 'workspace/didChangeWatchedFiles'.
Params: {"changes":[{"uri":"file:///artefacts/govim/cmd/govim-race/scenario_default/script-gofmt/file.go","type":2}]}

[Trace - 22:47:42.661 PM] Sending notification 'textDocument/didChange'.
Params: {"textDocument":{"version":5,"uri":"file:///artefacts/govim/cmd/govim-race/scenario_default/script-gofmt/file.go"},"contentChanges":[{"text":"package blah\n\nblah\n"}]}

[Trace - 22:47:42.665 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {"uri":"file:///artefacts/govim/cmd/govim-race/scenario_default/script-gofmt/file.go","version":5,"diagnostics":[{"range":{"start":{"line":2,"character":0},"end":{"line":2,"character":0}},"severity":1,"source":"syntax","message":"expected declaration, found blah"}]}

[Trace - 22:47:42.759 PM] Sending request 'textDocument/formatting - (4)'.
Params: {"textDocument":{"uri":"file:///artefacts/govim/cmd/govim-race/scenario_default/script-gofmt/file.go"},"options":{"tabSize":0,"insertSpaces":false}}

[Error - Received] 22:47:42.760 PM #4 3:1: expected declaration, found blah

[Trace - 22:47:42.761 PM] Sending notification 'workspace/didChangeWatchedFiles'.
Params: {"changes":[{"uri":"file:///artefacts/govim/cmd/govim-race/scenario_default/script-gofmt/file.go","type":2}]}

[Trace - 22:47:42.765 PM] Sending notification 'workspace/didChangeWatchedFiles'.
Params: {"changes":[{"uri":"file:///artefacts/govim/cmd/govim-race/scenario_default/script-gofmt/file.go","type":2}]}

[Trace - 22:47:42.766 PM] Sending notification 'textDocument/didSave'.
Params: {"textDocument":{"version":5,"uri":"file:///artefacts/govim/cmd/govim-race/scenario_default/script-gofmt/file.go"}}

[Trace - 22:47:42.770 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {"uri":"file:///artefacts/govim/cmd/govim-race/scenario_default/script-gofmt/file.go","version":5,"diagnostics":[]}

[Trace - 22:48:08.617 PM] Sending request 'shutdown - (5)'.
Params:

[Trace - 22:48:08.618 PM] Received response 'shutdown - (5)' in 0ms.
Result: null

[Trace - 22:48:08.619 PM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2020/11/24 22:48:08 Shutdown session\n\tshutdown_session=1\n"}

Another example where an empty 0-version is sent after a correct "version": 1:

[Trace - 22:53:34.272 PM] Sending request 'initialize - (1)'.
Params: {"processId":0,"clientInfo":{"name":""},"rootUri":"file:///artefacts/govim/cmd/govim-race/scenario_default/script-diagnostic_highlights","capabilities":{"Workspace":{"workspaceEdit":{},"didChangeConfiguration":{"dynamicRegistration":true},"didChangeWatchedFiles":{"dynamicRegistration":true},"symbol":{"symbolKind":{},"tagSupport":{"valueSet":null}},"executeCommand":{},"semanticTokens":{},"configuration":true},"textDocument":{"synchronization":{},"completion":{"completionItem":{"tagSupport":{"valueSet":null},"resolveSupport":{"properties":null}},"completionItemKind":{}},"hover":{"contentFormat":["plaintext"]},"signatureHelp":{"signatureInformation":{"parameterInformation":{}}},"declaration":{},"definition":{},"typeDefinition":{},"implementation":{},"references":{},"documentHighlight":{},"documentSymbol":{"symbolKind":{},"tagSupport":{"valueSet":null}},"codeAction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":null}},"resolveSupport":{"properties":null}},"codeLens":{},"documentLink":{},"colorProvider":{},"formatting":{},"rangeFormatting":{},"onTypeFormatting":{},"rename":{},"foldingRange":{},"selectionRange":{},"publishDiagnostics":{"tagSupport":{"valueSet":null}},"callHierarchy":{},"semanticTokens":{"requests":{},"tokenTypes":null,"tokenModifiers":null,"formats":null}},"Window":{"workDoneProgress":true}},"initializationOptions":{"symbolMatcher":"fuzzy","symbolStyle":"full"},"workspaceFolders":null}

[Trace - 22:53:34.278 PM] Received response 'initialize - (1)' in 5ms.
Result: {"capabilities":{"textDocumentSync":{"openClose":true,"change":2,"save":{}},"completionProvider":{"triggerCharacters":["."]},"hoverProvider":true,"signatureHelpProvider":{"triggerCharacters":["(",","]},"definitionProvider":true,"typeDefinitionProvider":true,"implementationProvider":true,"referencesProvider":true,"documentHighlightProvider":true,"documentSymbolProvider":true,"codeActionProvider":true,"codeLensProvider":{},"documentLinkProvider":{},"workspaceSymbolProvider":true,"documentFormattingProvider":true,"documentOnTypeFormattingProvider":{"firstTriggerCharacter":""},"renameProvider":true,"foldingRangeProvider":true,"executeCommandProvider":{"commands":["gopls.generate","gopls.fill_struct","gopls.regenerate_cgo","gopls.test","gopls.tidy","gopls.undeclared_name","gopls.add_dependency","gopls.upgrade_dependency","gopls.remove_dependency","gopls.vendor","gopls.extract_variable","gopls.extract_function","gopls.gc_details","gopls.generate_gopls_mod"]},"callHierarchyProvider":true,"workspace":{"workspaceFolders":{"supported":true,"changeNotifications":"workspace/didChangeWorkspaceFolders"}}},"serverInfo":{"name":"gopls","version":"{"path":"golang.org/x/tools/gopls","version":"v0.0.0-20201124202034-299f270db459","sum":"h1:nmlDEuxI9XQoUpls13E56e3+7RzC8jHtyrHi06sCbDk=","deps":[{"path":"github.com/BurntSushi/toml","version":"v0.3.1","sum":"h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ="},{"path":"github.com/google/go-cmp","version":"v0.5.1","sum":"h1:JFrFEBb2xKufg6XkJsJr+WbKb4FQlURi5RUcBveYu9k="},{"path":"github.com/sergi/go-diff","version":"v1.1.0","sum":"h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0="},{"path":"golang.org/x/mod","version":"v0.3.0","sum":"h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4="},{"path":"golang.org/x/sync","version":"v0.0.0-20201020160332-67f06af15bc9","sum":"h1:SQFwaSi55rU7vdNs9Yr0Z324VNlrF+0wMqRXT4St8ck="},{"path":"golang.org/x/tools","version":"v0.0.0-20201124202034-299f270db459","sum":"h1:XrUnpqJ8xqeZHrgPu3FuYCv9/O3MrxnIKh5/+MLDE8Q="},{"path":"golang.org/x/xerrors","version":"v0.0.0-20200804184101-5ec99f83aff1","sum":"h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE="},{"path":"honnef.co/go/tools","version":"v0.0.1-2020.1.6","sum":"h1:W18jzjh8mfPez+AwGLxmOImucz/IFjpNlrKVnaj2YVc="},{"path":"mvdan.cc/gofumpt","version":"v0.0.0-20200927160801-5bfeb2e70dd6","sum":"h1:z+/YqapuV7VZPvBb3GYmuEJbA88M3PFUxaHilHYVCpQ="},{"path":"mvdan.cc/xurls/v2","version":"v2.2.0","sum":"h1:NSZPykBXJFCetGZykLAxaL6SIpvbVy/UFEniIfHAa8A="}]}"}}

[Trace - 22:53:34.287 PM] Sending notification 'initialized'.
Params: {}

[Trace - 22:53:34.288 PM] Received request 'window/workDoneProgress/create - (1)'.
Params: {"token":"5577006791947779410"}

[Trace - 22:53:34.299 PM] Sending response 'window/workDoneProgress/create - (1)' in 11ms.
Result:

[Trace - 22:53:34.299 PM] Received notification '$/progress'.
Params: {"token":"5577006791947779410","value":{"kind":"begin","title":"Setting up workspace","message":"Loading packages..."}}

[Trace - 22:53:34.300 PM] Received request 'workspace/configuration - (2)'.
Params: {"items":[{"scopeUri":"file:///artefacts/govim/cmd/govim-race/scenario_default/script-diagnostic_highlights","section":"gopls"}]}

[Trace - 22:53:34.304 PM] Sending response 'workspace/configuration - (2)' in 3ms.
Result: [{"analyses":{},"codelens":{"gc_details":true},"completionBudget":"0ms","hoverKind":"FullDocumentation","staticcheck":false,"tempModfile":false,"verboseOutput":true}]

[Trace - 22:53:34.355 PM] Sending notification 'textDocument/didOpen'.
Params: {"textDocument":{"uri":"file:///artefacts/govim/cmd/govim-race/scenario_default/script-diagnostic_highlights/main.go","languageId":"go","version":1,"text":"package main\n\nimport "fmt"\n\nfunc main() {\n\tfmt.Printf("This is a test %v\n", i, v)\n}\n\nfunc f1() string {}\nfunc f2() string {}\n"}}

[Trace - 22:53:34.798 PM] Received request 'client/registerCapability - (3)'.
Params: {"registrations":[{"id":"workspace/didChangeWatchedFiles-0","method":"workspace/didChangeWatchedFiles","registerOptions":{"watchers":[{"globPattern":"**/*.{go,mod,sum}","kind":7}]}}]}

[Trace - 22:53:34.799 PM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2020/11/24 22:53:34 go env for /artefacts/govim/cmd/govim-race/scenario_default/script-diagnostic_highlights\n(root /artefacts/govim/cmd/govim-race/scenario_default/script-diagnostic_highlights)\n(go version go version go1.14.9 linux/amd64)\n(valid build configuration = true)\n(build flags: [])\nGOPATH=/artefacts/govim/cmd/govim-race/scenario_default/script-diagnostic_highlights/.home/gopath\nGO111MODULE=\nGOFLAGS=\nGOMOD=/artefacts/govim/cmd/govim-race/scenario_default/script-diagnostic_highlights/go.mod\nGOMODCACHE=\nGONOSUMDB=*\nGOPROXY=http://127.0.0.1:39103/mod\nGOSUMDB=sum.golang.org\nGOPRIVATE=\nGOINSECURE=\nGONOPROXY=\nGOROOT=/go\nGOCACHE=/home/runner/.cache/go-build\n\n"}

[Trace - 22:53:34.802 PM] Sending response 'client/registerCapability - (3)' in 4ms.
Result:

[Trace - 22:53:34.803 PM] Received request 'client/registerCapability - (4)'.
Params: {"registrations":[{"id":"workspace/didChangeConfiguration","method":"workspace/didChangeConfiguration"},{"id":"workspace/didChangeWorkspaceFolders","method":"workspace/didChangeWorkspaceFolders"}]}

[Trace - 22:53:34.805 PM] Sending response 'client/registerCapability - (4)' in 2ms.
Result:

[Trace - 22:53:34.816 PM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2020/11/24 22:53:34 59.663629ms for GOROOT=/go GOPATH=/artefacts/govim/cmd/govim-race/scenario_default/script-diagnostic_highlights/.home/gopath GO111MODULE= GOPROXY=http://127.0.0.1:39103/mod PWD=/artefacts/govim/cmd/govim-race/scenario_default/script-diagnostic_highlights go list -f "{{context.GOARCH}} {{context.Compiler}}" -- unsafe\n"}

[Trace - 22:53:34.854 PM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2020/11/24 22:53:34 98.229441ms for GOROOT=/go GOPATH=/artefacts/govim/cmd/govim-race/scenario_default/script-diagnostic_highlights/.home/gopath GO111MODULE=off GOPROXY=http://127.0.0.1:39103/mod PWD=/artefacts/govim/cmd/govim-race/scenario_default/script-diagnostic_highlights go list -e -f {{context.ReleaseTags}}\n"}

[Trace - 22:53:35.045 PM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2020/11/24 22:53:35 185.39772ms for GOROOT=/go GOPATH=/artefacts/govim/cmd/govim-race/scenario_default/script-diagnostic_highlights/.home/gopath GO111MODULE= GOPROXY=http://127.0.0.1:39103/mod PWD=/artefacts/govim/cmd/govim-race/scenario_default/script-diagnostic_highlights go list -e -json -compiled=true -test=true -export=false -deps=true -find=false -- builtin mod.com/...\n"}

[Trace - 22:53:35.088 PM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2020/11/24 22:53:35 6.719537ms for GOROOT=/go GOPATH=/artefacts/govim/cmd/govim-race/scenario_default/script-diagnostic_highlights/.home/gopath GO111MODULE= GOPROXY=http://127.0.0.1:39103/mod PWD=/artefacts/govim/cmd/govim-race/scenario_default/script-diagnostic_highlights go env -json GOMOD GOPATH\n"}

[Trace - 22:53:35.089 PM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2020/11/24 22:53:35 go/packages.Load\n\tsnapshot=0\n\tdirectory=/artefacts/govim/cmd/govim-race/scenario_default/script-diagnostic_highlights\n\tquery=[builtin mod.com/...]\n\tpackages=2\n"}

[Trace - 22:53:35.089 PM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2020/11/24 22:53:35 go/packages.Load\n\tsnapshot=0\n\tpackage_path="builtin"\n\tfiles=[/go/src/builtin/builtin.go]\n"}

[Trace - 22:53:35.097 PM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2020/11/24 22:53:35 go/packages.Load\n\tsnapshot=0\n\tpackage_path="mod.com"\n\tfiles=[/artefacts/govim/cmd/govim-race/scenario_default/script-diagnostic_highlights/main.go /artefacts/govim/cmd/govim-race/scenario_default/script-diagnostic_highlights/other.go]\n"}

[Trace - 22:53:35.268 PM] Received notification '$/progress'.
Params: {"token":"5577006791947779410","value":{"kind":"end","message":"Finished loading packages."}}

[Trace - 22:53:38.559 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {"uri":"file:///artefacts/govim/cmd/govim-race/scenario_default/script-diagnostic_highlights/main.go","version":1,"diagnostics":[{"range":{"start":{"line":5,"character":35},"end":{"line":5,"character":36}},"severity":1,"source":"compiler","message":"undeclared name: i"},{"range":{"start":{"line":5,"character":38},"end":{"line":5,"character":39}},"severity":1,"source":"compiler","message":"undeclared name: v"},{"range":{"start":{"line":8,"character":18},"end":{"line":8,"character":19}},"severity":1,"source":"compiler","message":"missing return"},{"range":{"start":{"line":9,"character":18},"end":{"line":9,"character":19}},"severity":1,"source":"compiler","message":"missing return"}]}

[Trace - 22:53:38.560 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {"uri":"file:///artefacts/govim/cmd/govim-race/scenario_default/script-diagnostic_highlights/main.go","diagnostics":[]}

[Trace - 22:54:00.186 PM] Sending request 'shutdown - (2)'.
Params:

[Trace - 22:54:00.187 PM] Received response 'shutdown - (2)' in 1ms.
Result: null

[Trace - 22:54:00.190 PM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2020/11/24 22:54:00 Shutdown session\n\tshutdown_session=1\n"}

What did you expect to see?

In these two cases, no second publishDiagnostics with empty diagnostics.

//cc @findleyr

@gopherbot gopherbot added this to the Unreleased milestone Nov 25, 2020
@leitzler
Copy link
Contributor Author

@leitzler leitzler commented Nov 25, 2020

Another example of duplicate "version": 5, this occurred in a test that didn't run with race detection enabled.

[Trace - 09:19:01.307 AM] Sending request 'initialize - (1)'.
Params: {"processId":0,"clientInfo":{"name":""},"rootUri":"file:///artefacts/govim/cmd/govim/scenario_default/script-gofmt","capabilities":{"Workspace":{"workspaceEdit":{},"didChangeConfiguration":{"dynamicRegistration":true},"didChangeWatchedFiles":{"dynamicRegistration":true},"symbol":{"symbolKind":{},"tagSupport":{"valueSet":null}},"executeCommand":{},"semanticTokens":{},"configuration":true},"textDocument":{"synchronization":{},"completion":{"completionItem":{"tagSupport":{"valueSet":null},"resolveSupport":{"properties":null}},"completionItemKind":{}},"hover":{"contentFormat":["plaintext"]},"signatureHelp":{"signatureInformation":{"parameterInformation":{}}},"declaration":{},"definition":{},"typeDefinition":{},"implementation":{},"references":{},"documentHighlight":{},"documentSymbol":{"symbolKind":{},"tagSupport":{"valueSet":null}},"codeAction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":null}},"resolveSupport":{"properties":null}},"codeLens":{},"documentLink":{},"colorProvider":{},"formatting":{},"rangeFormatting":{},"onTypeFormatting":{},"rename":{},"foldingRange":{},"selectionRange":{},"publishDiagnostics":{"tagSupport":{"valueSet":null}},"callHierarchy":{},"semanticTokens":{"requests":{},"tokenTypes":null,"tokenModifiers":null,"formats":null}},"Window":{"workDoneProgress":true}},"initializationOptions":{"symbolMatcher":"fuzzy","symbolStyle":"full"},"workspaceFolders":null}

[Trace - 09:19:01.308 AM] Received response 'initialize - (1)' in 1ms.
Result: {"capabilities":{"textDocumentSync":{"openClose":true,"change":2,"save":{}},"completionProvider":{"triggerCharacters":["."]},"hoverProvider":true,"signatureHelpProvider":{"triggerCharacters":["(",","]},"definitionProvider":true,"typeDefinitionProvider":true,"implementationProvider":true,"referencesProvider":true,"documentHighlightProvider":true,"documentSymbolProvider":true,"codeActionProvider":true,"codeLensProvider":{},"documentLinkProvider":{},"workspaceSymbolProvider":true,"documentFormattingProvider":true,"documentOnTypeFormattingProvider":{"firstTriggerCharacter":""},"renameProvider":true,"foldingRangeProvider":true,"executeCommandProvider":{"commands":["gopls.generate","gopls.fill_struct","gopls.regenerate_cgo","gopls.test","gopls.tidy","gopls.undeclared_name","gopls.add_dependency","gopls.upgrade_dependency","gopls.remove_dependency","gopls.vendor","gopls.extract_variable","gopls.extract_function","gopls.gc_details","gopls.generate_gopls_mod"]},"callHierarchyProvider":true,"workspace":{"workspaceFolders":{"supported":true,"changeNotifications":"workspace/didChangeWorkspaceFolders"}}},"serverInfo":{"name":"gopls","version":"{"path":"golang.org/x/tools/gopls","version":"v0.0.0-20201124202034-299f270db459","sum":"h1:nmlDEuxI9XQoUpls13E56e3+7RzC8jHtyrHi06sCbDk=","deps":[{"path":"github.com/BurntSushi/toml","version":"v0.3.1","sum":"h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ="},{"path":"github.com/google/go-cmp","version":"v0.5.1","sum":"h1:JFrFEBb2xKufg6XkJsJr+WbKb4FQlURi5RUcBveYu9k="},{"path":"github.com/sergi/go-diff","version":"v1.1.0","sum":"h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0="},{"path":"golang.org/x/mod","version":"v0.3.0","sum":"h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4="},{"path":"golang.org/x/sync","version":"v0.0.0-20201020160332-67f06af15bc9","sum":"h1:SQFwaSi55rU7vdNs9Yr0Z324VNlrF+0wMqRXT4St8ck="},{"path":"golang.org/x/tools","version":"v0.0.0-20201124202034-299f270db459","sum":"h1:XrUnpqJ8xqeZHrgPu3FuYCv9/O3MrxnIKh5/+MLDE8Q="},{"path":"golang.org/x/xerrors","version":"v0.0.0-20200804184101-5ec99f83aff1","sum":"h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE="},{"path":"honnef.co/go/tools","version":"v0.0.1-2020.1.6","sum":"h1:W18jzjh8mfPez+AwGLxmOImucz/IFjpNlrKVnaj2YVc="},{"path":"mvdan.cc/gofumpt","version":"v0.0.0-20200927160801-5bfeb2e70dd6","sum":"h1:z+/YqapuV7VZPvBb3GYmuEJbA88M3PFUxaHilHYVCpQ="},{"path":"mvdan.cc/xurls/v2","version":"v2.2.0","sum":"h1:NSZPykBXJFCetGZykLAxaL6SIpvbVy/UFEniIfHAa8A="}]}"}}

[Trace - 09:19:01.309 AM] Sending notification 'initialized'.
Params: {}

[Trace - 09:19:01.309 AM] Received request 'window/workDoneProgress/create - (1)'.
Params: {"token":"5577006791947779410"}

[Trace - 09:19:01.314 AM] Sending response 'window/workDoneProgress/create - (1)' in 5ms.
Result:

[Trace - 09:19:01.314 AM] Received notification '$/progress'.
Params: {"token":"5577006791947779410","value":{"kind":"begin","title":"Setting up workspace","message":"Loading packages..."}}

[Trace - 09:19:01.314 AM] Received request 'workspace/configuration - (2)'.
Params: {"items":[{"scopeUri":"file:///artefacts/govim/cmd/govim/scenario_default/script-gofmt","section":"gopls"}]}

[Trace - 09:19:01.318 AM] Sending response 'workspace/configuration - (2)' in 3ms.
Result: [{"analyses":{},"codelens":{"gc_details":true},"completionBudget":"0ms","hoverKind":"FullDocumentation","staticcheck":false,"tempModfile":false,"verboseOutput":true}]

[Trace - 09:19:01.337 AM] Sending notification 'textDocument/didOpen'.
Params: {"textDocument":{"uri":"file:///artefacts/govim/cmd/govim/scenario_default/script-gofmt/file.go","languageId":"go","version":1,"text":"package blah\n\nconst ( x = 5\ny = x\n )\n\n"}}

[Trace - 09:19:01.338 AM] Sending request 'textDocument/formatting - (2)'.
Params: {"textDocument":{"uri":"file:///artefacts/govim/cmd/govim/scenario_default/script-gofmt/file.go"},"options":{"tabSize":0,"insertSpaces":false}}

[Trace - 09:19:01.364 AM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2020/11/25 09:19:01 8.724994ms for GOROOT=/go GOPATH=/artefacts/govim/cmd/govim/scenario_default/script-gofmt/.home/gopath GO111MODULE= GOPROXY=http://127.0.0.1:45151/mod PWD=/artefacts/govim/cmd/govim/scenario_default/script-gofmt go list -f "{{context.GOARCH}} {{context.Compiler}}" -- unsafe\n"}

[Trace - 09:19:01.365 AM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2020/11/25 09:19:01 9.561294ms for GOROOT=/go GOPATH=/artefacts/govim/cmd/govim/scenario_default/script-gofmt/.home/gopath GO111MODULE=off GOPROXY=http://127.0.0.1:45151/mod PWD=/artefacts/govim/cmd/govim/scenario_default/script-gofmt go list -e -f {{context.ReleaseTags}}\n"}

[Trace - 09:19:01.369 AM] Received request 'client/registerCapability - (3)'.
Params: {"registrations":[{"id":"workspace/didChangeWatchedFiles-0","method":"workspace/didChangeWatchedFiles","registerOptions":{"watchers":[{"globPattern":"**/*.{go,mod,sum}","kind":7}]}}]}

[Trace - 09:19:01.369 AM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2020/11/25 09:19:01 go env for /artefacts/govim/cmd/govim/scenario_default/script-gofmt\n(root /artefacts/govim/cmd/govim/scenario_default/script-gofmt)\n(go version go version go1.14.9 linux/amd64)\n(valid build configuration = true)\n(build flags: [])\nGOSUMDB=sum.golang.org\nGOMODCACHE=\nGOPATH=/artefacts/govim/cmd/govim/scenario_default/script-gofmt/.home/gopath\nGO111MODULE=\nGOINSECURE=\nGONOSUMDB=*\nGOPRIVATE=\nGOMOD=/artefacts/govim/cmd/govim/scenario_default/script-gofmt/go.mod\nGONOPROXY=\nGOFLAGS=\nGOPROXY=http://127.0.0.1:45151/mod\nGOROOT=/go\nGOCACHE=/home/runner/.cache/go-build\n\n"}

[Trace - 09:19:01.371 AM] Sending response 'client/registerCapability - (3)' in 1ms.
Result:

[Trace - 09:19:01.371 AM] Received request 'client/registerCapability - (4)'.
Params: {"registrations":[{"id":"workspace/didChangeConfiguration","method":"workspace/didChangeConfiguration"},{"id":"workspace/didChangeWorkspaceFolders","method":"workspace/didChangeWorkspaceFolders"}]}

[Trace - 09:19:01.373 AM] Sending response 'client/registerCapability - (4)' in 2ms.
Result:

[Trace - 09:19:01.381 AM] Received notification '$/progress'.
Params: {"token":"5577006791947779410","value":{"kind":"end","message":"Finished loading packages."}}

[Trace - 09:19:01.381 AM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2020/11/25 09:19:01 15.553789ms for GOROOT=/go GOPATH=/artefacts/govim/cmd/govim/scenario_default/script-gofmt/.home/gopath GO111MODULE= GOPROXY=http://127.0.0.1:45151/mod PWD=/artefacts/govim/cmd/govim/scenario_default/script-gofmt go list -e -json -compiled=true -test=true -export=false -deps=true -find=false -- builtin mod.com/...\n"}

[Trace - 09:19:01.381 AM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2020/11/25 09:19:01 go/packages.Load\n\tsnapshot=0\n\tdirectory=/artefacts/govim/cmd/govim/scenario_default/script-gofmt\n\tquery=[builtin mod.com/...]\n\tpackages=2\n"}

[Trace - 09:19:01.381 AM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2020/11/25 09:19:01 go/packages.Load\n\tsnapshot=0\n\tpackage_path="builtin"\n\tfiles=[/go/src/builtin/builtin.go]\n"}

[Trace - 09:19:01.382 AM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2020/11/25 09:19:01 go/packages.Load\n\tsnapshot=0\n\tpackage_path="mod.com"\n\tfiles=[/artefacts/govim/cmd/govim/scenario_default/script-gofmt/file.go]\n"}

[Trace - 09:19:01.382 AM] Received response 'textDocument/formatting - (2)' in 44ms.
Result: [{"range":{"start":{"line":2,"character":7},"end":{"line":2,"character":8}},"newText":""},{"range":{"start":{"line":2,"character":8},"end":{"line":2,"character":8}},"newText":"\n\t"},{"range":{"start":{"line":3,"character":0},"end":{"line":3,"character":0}},"newText":"\t"},{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":1}},"newText":""},{"range":{"start":{"line":5,"character":0},"end":{"line":6,"character":0}},"newText":""}]

[Trace - 09:19:01.385 AM] Sending notification 'textDocument/didChange'.
Params: {"textDocument":{"version":2,"uri":"file:///artefacts/govim/cmd/govim/scenario_default/script-gofmt/file.go"},"contentChanges":[{"text":"package blah\n\nconst (\n\tx = 5\n\ty = x\n)\n"}]}

[Trace - 09:19:01.394 AM] Sending notification 'workspace/didChangeWatchedFiles'.
Params: {"changes":[{"uri":"file:///artefacts/govim/cmd/govim/scenario_default/script-gofmt/file.go","type":2}]}

[Trace - 09:19:01.395 AM] Sending notification 'workspace/didChangeWatchedFiles'.
Params: {"changes":[{"uri":"file:///artefacts/govim/cmd/govim/scenario_default/script-gofmt/file.go","type":2}]}

[Trace - 09:19:01.397 AM] Sending notification 'workspace/didChangeWatchedFiles'.
Params: {"changes":[{"uri":"file:///artefacts/govim/cmd/govim/scenario_default/script-gofmt/file.go","type":2}]}

[Trace - 09:19:01.397 AM] Sending notification 'workspace/didChangeWatchedFiles'.
Params: {"changes":[{"uri":"file:///artefacts/govim/cmd/govim/scenario_default/script-gofmt/file.go","type":2}]}

[Trace - 09:19:01.402 AM] Sending notification 'workspace/didChangeConfiguration'.
Params: {"settings":null}

[Trace - 09:19:01.402 AM] Received request 'workspace/configuration - (5)'.
Params: {"items":[{"section":"gopls"}]}

[Trace - 09:19:01.403 AM] Sending response 'workspace/configuration - (5)' in 0ms.
Result: [{"analyses":{},"codelens":{"gc_details":true},"completionBudget":"0ms","hoverKind":"FullDocumentation","staticcheck":false,"tempModfile":false,"verboseOutput":true}]

[Trace - 09:19:01.403 AM] Received request 'workspace/configuration - (6)'.
Params: {"items":[{"scopeUri":"file:///artefacts/govim/cmd/govim/scenario_default/script-gofmt","section":"gopls"}]}

[Trace - 09:19:01.403 AM] Sending response 'workspace/configuration - (6)' in 0ms.
Result: [{"analyses":{},"codelens":{"gc_details":true},"completionBudget":"0ms","hoverKind":"FullDocumentation","staticcheck":false,"tempModfile":false,"verboseOutput":true}]

[Trace - 09:19:01.412 AM] Sending notification 'textDocument/didChange'.
Params: {"textDocument":{"version":3,"uri":"file:///artefacts/govim/cmd/govim/scenario_default/script-gofmt/file.go"},"contentChanges":[{"text":"package blah\n\nconst ( x = 5\ny = x\n )\n\n"}]}

[Trace - 09:19:01.461 AM] Sending request 'textDocument/formatting - (3)'.
Params: {"textDocument":{"uri":"file:///artefacts/govim/cmd/govim/scenario_default/script-gofmt/file.go"},"options":{"tabSize":0,"insertSpaces":false}}

[Trace - 09:19:01.462 AM] Received response 'textDocument/formatting - (3)' in 0ms.
Result: [{"range":{"start":{"line":2,"character":7},"end":{"line":2,"character":8}},"newText":""},{"range":{"start":{"line":2,"character":8},"end":{"line":2,"character":8}},"newText":"\n\t"},{"range":{"start":{"line":3,"character":0},"end":{"line":3,"character":0}},"newText":"\t"},{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":1}},"newText":""},{"range":{"start":{"line":5,"character":0},"end":{"line":6,"character":0}},"newText":""}]

[Trace - 09:19:01.464 AM] Sending notification 'textDocument/didChange'.
Params: {"textDocument":{"version":4,"uri":"file:///artefacts/govim/cmd/govim/scenario_default/script-gofmt/file.go"},"contentChanges":[{"text":"package blah\n\nconst (\n\tx = 5\n\ty = x\n)\n"}]}

[Trace - 09:19:01.466 AM] Sending notification 'workspace/didChangeWatchedFiles'.
Params: {"changes":[{"uri":"file:///artefacts/govim/cmd/govim/scenario_default/script-gofmt/file.go","type":2}]}

[Trace - 09:19:01.466 AM] Sending notification 'workspace/didChangeWatchedFiles'.
Params: {"changes":[{"uri":"file:///artefacts/govim/cmd/govim/scenario_default/script-gofmt/file.go","type":2}]}

[Trace - 09:19:01.468 AM] Sending notification 'workspace/didChangeWatchedFiles'.
Params: {"changes":[{"uri":"file:///artefacts/govim/cmd/govim/scenario_default/script-gofmt/file.go","type":2}]}

[Trace - 09:19:01.470 AM] Sending notification 'textDocument/didSave'.
Params: {"textDocument":{"version":4,"uri":"file:///artefacts/govim/cmd/govim/scenario_default/script-gofmt/file.go"}}

[Trace - 09:19:01.473 AM] Sending notification 'workspace/didChangeWatchedFiles'.
Params: {"changes":[{"uri":"file:///artefacts/govim/cmd/govim/scenario_default/script-gofmt/file.go","type":2}]}

[Trace - 09:19:01.474 AM] Sending notification 'workspace/didChangeWatchedFiles'.
Params: {"changes":[{"uri":"file:///artefacts/govim/cmd/govim/scenario_default/script-gofmt/file.go","type":2}]}

[Trace - 09:19:01.481 AM] Sending notification 'textDocument/didChange'.
Params: {"textDocument":{"version":5,"uri":"file:///artefacts/govim/cmd/govim/scenario_default/script-gofmt/file.go"},"contentChanges":[{"text":"package blah\n\nblah\n"}]}

[Trace - 09:19:01.482 AM] Received notification 'textDocument/publishDiagnostics'.
Params: {"uri":"file:///artefacts/govim/cmd/govim/scenario_default/script-gofmt/file.go","version":5,"diagnostics":[{"range":{"start":{"line":2,"character":0},"end":{"line":2,"character":0}},"severity":1,"source":"syntax","message":"expected declaration, found blah"}]}

[Trace - 09:19:01.533 AM] Sending request 'textDocument/formatting - (4)'.
Params: {"textDocument":{"uri":"file:///artefacts/govim/cmd/govim/scenario_default/script-gofmt/file.go"},"options":{"tabSize":0,"insertSpaces":false}}

[Error - Received] 09:19:01.533 AM #4 3:1: expected declaration, found blah

[Trace - 09:19:01.534 AM] Sending notification 'workspace/didChangeWatchedFiles'.
Params: {"changes":[{"uri":"file:///artefacts/govim/cmd/govim/scenario_default/script-gofmt/file.go","type":2}]}

[Trace - 09:19:01.534 AM] Sending notification 'workspace/didChangeWatchedFiles'.
Params: {"changes":[{"uri":"file:///artefacts/govim/cmd/govim/scenario_default/script-gofmt/file.go","type":2}]}

[Trace - 09:19:01.536 AM] Sending notification 'textDocument/didSave'.
Params: {"textDocument":{"version":5,"uri":"file:///artefacts/govim/cmd/govim/scenario_default/script-gofmt/file.go"}}

[Trace - 09:19:01.536 AM] Sending notification 'workspace/didChangeWatchedFiles'.
Params: {"changes":[{"uri":"file:///artefacts/govim/cmd/govim/scenario_default/script-gofmt/file.go","type":2}]}

[Trace - 09:19:01.537 AM] Received notification 'textDocument/publishDiagnostics'.
Params: {"uri":"file:///artefacts/govim/cmd/govim/scenario_default/script-gofmt/file.go","version":5,"diagnostics":[]}

[Trace - 09:19:27.294 AM] Sending request 'shutdown - (5)'.
Params:

[Trace - 09:19:27.295 AM] Received response 'shutdown - (5)' in 0ms.
Result: null

[Trace - 09:19:27.295 AM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2020/11/25 09:19:27 Shutdown session\n\tshutdown_session=1\n"}

@gopherbot
Copy link

@gopherbot gopherbot commented Dec 1, 2020

Change https://golang.org/cl/274241 mentions this issue: internal/lsp: restore snapshot ID guard for published diagnostics

gopherbot pushed a commit to golang/tools that referenced this issue Dec 1, 2020
A guard against publishing stale diagnostics was removed in CL 269677,
because the signficance of diagnoseDetached was overlooked. Restore it.

For golang/go#42837

Change-Id: I911c4707a9c18a632ce32e0c25c43ae2e92135b2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/274241
Run-TryBot: Robert Findley <rfindley@google.com>
Trust: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
@gopherbot
Copy link

@gopherbot gopherbot commented Dec 4, 2020

Change https://golang.org/cl/275238 mentions this issue: internal/lsp: update diagnostic snapshotID even if not published

@gopherbot
Copy link

@gopherbot gopherbot commented Dec 4, 2020

Change https://golang.org/cl/275239 mentions this issue: internal/lsp: move the background context onto the snapshot

vscode-go: gopls by default automation moved this from Critical to Done Dec 4, 2020
gopherbot pushed a commit to golang/tools that referenced this issue Dec 4, 2020
There was a race to the background context that allowed work for earlier
snapshots to run on the background context of later snapshots. For
example, the following sequence is possible and has been observed in
tests (admittedly at unrealistic time scales):
 - snapshot N is created
 - view.cancelBackground() is called
 - snapshot N+1 is created
 - snapshot N+1 is diagnosed
 - snapshot N is diagnosed
 - snapshot N is destroyed

Fix this by pinning the background context to the snapshot. This also
makes more sense; I'm guessing the background context being on view is a
vestige of when more work was done on the view.

For golang/go#42837

Change-Id: If9cbad7361de823da9bfd2f55cb2f8b3aed95075
Reviewed-on: https://go-review.googlesource.com/c/tools/+/275239
Run-TryBot: Robert Findley <rfindley@google.com>
Trust: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
marwan-at-work added a commit to marwan-at-work/tools that referenced this issue Dec 23, 2020
The LSP server tracks the snapshot ID for which diagnostics were last
published, but this ID was not being updated if the publish was
suppressed when there are no changes, which can cause incorrect
diagnostics when snapshots are published out-of-order (a separate bug).

Fix this to update the snapshot ID when the current published
diagnostics match the latest computed diagnostics.

Fixes golang/go#42837

Change-Id: I3634e6f351a479aefa5c9423956720431590d814
Reviewed-on: https://go-review.googlesource.com/c/tools/+/275238
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Robert Findley <rfindley@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
marwan-at-work added a commit to marwan-at-work/tools that referenced this issue Dec 23, 2020
There was a race to the background context that allowed work for earlier
snapshots to run on the background context of later snapshots. For
example, the following sequence is possible and has been observed in
tests (admittedly at unrealistic time scales):
 - snapshot N is created
 - view.cancelBackground() is called
 - snapshot N+1 is created
 - snapshot N+1 is diagnosed
 - snapshot N is diagnosed
 - snapshot N is destroyed

Fix this by pinning the background context to the snapshot. This also
makes more sense; I'm guessing the background context being on view is a
vestige of when more work was done on the view.

For golang/go#42837

Change-Id: If9cbad7361de823da9bfd2f55cb2f8b3aed95075
Reviewed-on: https://go-review.googlesource.com/c/tools/+/275239
Run-TryBot: Robert Findley <rfindley@google.com>
Trust: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants