golang / vscode-go

Go extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=golang.Go
Other
3.8k stars 730 forks source link

[error] TypeError: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined #3123

Closed mynkkmr closed 6 months ago

mynkkmr commented 6 months ago

Issue Description

I encountered an issue while trying to use the Golang Debug Mode in the VSCode plugin. The error message indicates a TypeError: Cannot read properties of undefined (reading 'GOPATH'). This issue seems to be originating from the notificationsAlerts.ts file at line 40.

2024-01-12 00:12:07.628 [info] Extension host with pid 18790 exiting with code 0
2024-01-12 00:12:09.373 [info] Extension host with pid 19359 started
2024-01-12 00:12:09.373 [info] Skipping acquiring lock for /Users/mayankkumar/Library/Application Support/Code/User/workspaceStorage/e7b0658a6e10cee6c7b78e5ff5e84aa1.
2024-01-12 00:12:09.459 [info] ExtensionService#_doActivateExtension vscode.emmet, startup: false, activationEvent: 'onLanguage'
2024-01-12 00:12:09.467 [info] ExtensionService#_doActivateExtension vscode.json-language-features, startup: false, activationEvent: 'onLanguage:jsonc'
2024-01-12 00:12:09.487 [info] ExtensionService#_doActivateExtension vscode.typescript-language-features, startup: false, activationEvent: 'onLanguage:jsonc'
2024-01-12 00:12:09.865 [info] ExtensionService#_doActivateExtension vscode.git-base, startup: true, activationEvent: '*', root cause: vscode.git
2024-01-12 00:12:10.004 [info] ExtensionService#_doActivateExtension vscode.git, startup: true, activationEvent: '*'
2024-01-12 00:12:10.027 [info] ExtensionService#_doActivateExtension vscode.github, startup: true, activationEvent: '*'
2024-01-12 00:12:10.078 [info] ExtensionService#_doActivateExtension pulumi.pulumi-lsp-client, startup: true, activationEvent: 'workspaceContains:**/Pulumi.yaml,**/Main.yaml'
2024-01-12 00:12:10.120 [info] Eager extensions activated
2024-01-12 00:12:10.134 [info] ExtensionService#_doActivateExtension vscode.debug-auto-launch, startup: false, activationEvent: 'onStartupFinished'
2024-01-12 00:12:10.138 [info] ExtensionService#_doActivateExtension vscode.merge-conflict, startup: false, activationEvent: 'onStartupFinished'
2024-01-12 00:12:10.145 [info] ExtensionService#_doActivateExtension babakks.vscode-dap-inspector, startup: false, activationEvent: 'onStartupFinished'
2024-01-12 00:12:10.148 [info] ExtensionService#_doActivateExtension codeeras.base-64, startup: false, activationEvent: 'onStartupFinished'
2024-01-12 00:12:42.484 [info] ExtensionService#_doActivateExtension vscode.debug-server-ready, startup: false, activationEvent: 'onDebugResolve'
2024-01-12 00:12:42.487 [error] Activating extension vscode.debug-server-ready failed due to an error:
2024-01-12 00:12:42.487 [error] TypeError: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined
    at new NodeError (node:internal/errors:399:5)
    at Hash.update (node:internal/crypto/hash:109:11)
    at n._getCachedDataPath (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/loader.js:4:2987)
    at o._compile (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/loader.js:4:967)
    at Module._extensions..js (node:internal/modules/cjs/loader:1371:10)
    at Module.load (node:internal/modules/cjs/loader:1171:32)
    at Module._load (node:internal/modules/cjs/loader:1012:12)
    at f._load (node:electron/js2c/asar_bundle:2:13377)
    at c._load (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:171:5632)
    at n._load (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:168:29551)
    at t._load (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:133:35226)
    at Module.require (node:internal/modules/cjs/loader:1195:19)
    at require (node:internal/modules/cjs/helpers:110:18)
    at Function.i [as __$__nodeRequire] (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/loader.js:5:98)
    at f.vb (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:168:30730)
    at async Promise.all (index 0)
2024-01-12 00:12:42.487 [info] ExtensionService#_doActivateExtension golang.go, startup: false, activationEvent: 'onDebugResolve:go'
2024-01-12 00:12:42.492 [error] Activating extension golang.go failed due to an error:
2024-01-12 00:12:42.492 [error] TypeError: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined
    at new NodeError (node:internal/errors:399:5)
    at Hash.update (node:internal/crypto/hash:109:11)
    at n._getCachedDataPath (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/loader.js:4:2987)
    at o._compile (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/loader.js:4:967)
    at Module._extensions..js (node:internal/modules/cjs/loader:1371:10)
    at Module.load (node:internal/modules/cjs/loader:1171:32)
    at Module._load (node:internal/modules/cjs/loader:1012:12)
    at f._load (node:electron/js2c/asar_bundle:2:13377)
    at c._load (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:171:5632)
    at n._load (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:168:29551)
    at t._load (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:133:35226)
    at Module.require (node:internal/modules/cjs/loader:1195:19)
    at require (node:internal/modules/cjs/helpers:110:18)
    at Function.i [as __$__nodeRequire] (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/loader.js:5:98)
    at f.vb (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:168:30730)
    at async Promise.all (index 0)
Screenshot 2024-01-12 at 12 15 43 AM

Steps to Reproduce

  1. Open Visual Studio Code.
  2. Install the Golang plugin version 0.40.1
  3. Set up a Golang project.
  4. Attempt to use Golang Debug Mode.

Environment Details

Version: 1.85.1 (Universal)
Commit: 0ee08df0cf4527e40edc9aa28f4b5bd38bbff2b2
Date: 2023-12-13T09:48:06.308Z
Electron: 25.9.7
ElectronBuildId: 25551756
Chromium: 114.0.5735.289
Node.js: 18.15.0
V8: 11.4.183.29-electron.0
OS: Darwin x64 23.2.0
hyangah commented 6 months ago

Given that golang.go is not the only extension that failed with the error (vscode.debug-server-ready, which is VS Code's internal extension) also failed, and the stack trace doesn't indicate this extension code path, I guess this is a vscode's issue.

Can you reinstall VS Code and Go extension? If the problem doesn't go away, please open an issue to github.com/microsoft/vscode mentioning vscode.debug-server-ready extension's failure. Thanks!

mynkkmr commented 6 months ago

@hyangah I tried the steps you shared after seeing no progress I reported out to vs code team. And they replied it is the plugin problem.

https://github.com/microsoft/vscode/issues/202316

mynkkmr commented 6 months ago

I wanted to provide an update regarding the issue we discussed. After some investigation, I found that the root cause of the problem was the lingering extension folder in VSCode.

I deleted the extension folder, which was left behind even after uninstallation. Surprisingly, this resolved the issue I was facing. Everything seems to be working as expected now. Thanks to @hyangah for the invaluable assistance!