question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Extension tests improperly activate instance from dist folder

See original GitHub issue

I have come across an issue with an extension I am working on where the extension tests seem to be launching my webpacked extension from dist which causes intermittent failures due to commands being registered twice in classes that are supposed to be singletons among other things.

This has started happening after changing activation events to the following: "activationEvents": [ "*" ] (e.g., activating my extension on startup of VSCode).

If the dist folder does not exist, then my tests work as expected but produce a stacktrace similar to:

Activating extension `vscode-samples.webpack-sample` failed:  Cannot find module '/Users/minardi/vscode-extension-samples/webpack-sample/dist/extension'
Require stack:
- /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/loader.js
- /Applications/Visual Studio Code.app/Contents/Resources/app/out/bootstrap-amd.js
- /Applications/Visual Studio Code.app/Contents/Resources/app/out/bootstrap-fork.js
Here is the error stack:  Error: Cannot find module '/Users/minardi/vscode-extension-samples/webpack-sample/dist/extension'
Require stack:
- /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/loader.js
- /Applications/Visual Studio Code.app/Contents/Resources/app/out/bootstrap-amd.js
- /Applications/Visual Studio Code.app/Contents/Resources/app/out/bootstrap-fork.js
	at Function._resolveFilename (internal/modules/cjs/loader.js:627:15)
	at Function.<anonymous> (internal/modules/cjs/loader.js:531:27)
	at Function.<anonymous> (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:796:852)
	at Function.<anonymous> (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:765:302)
	at Function._load (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:761:870)
	at Module.require (internal/modules/cjs/loader.js:685:19)
	at require (internal/modules/cjs/helpers.js:16:16)
	at Function.s [as __$__nodeRequire] (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/loader.js:32:963)
	at d._loadCommonJSModule (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:766:484)
	at d._doActivateExtension (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:677:300)
	at d._activateExtension (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:676:360)
	at Object.actualActivateExtension (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:674:296)
	at Object._activateExtension (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:506:21)
	at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:505:632
	at Array.map (<anonymous>)
	at Object._activateExtensions (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:505:620)
	at Object.activateByEvent (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:503:413)
	at d._activateByEvent (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:675:24)
	at d._handleEagerExtensions (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:678:800)
	at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:682:215

  Dummy Suite
    ✓ Dummy Test
  1 passing (26ms)

which again seems to imply that the extension from dist is being loaded at some point. I also added --disable-extensions to the launch.json as a sanity measure and that seems to have no effect.

I would expect that the extension from the dist folder is not activated in this way and that the source from out/test/ is used instead.

I have forked the webpack example extension and added logic which will demonstrate this behaviour (at https://github.com/mpminardi/vscode-extension-samples/tree/activation-bug)

Version Information:

  • VSCode Version: Version: 1.40.2 Commit: f359dd69833dd8800b54d458f6d37ab7c78df520
  • OS Version: Mac OS X 10.14.6

Steps to Reproduce:

  1. Clone and checkout https://github.com/mpminardi/vscode-extension-samples/tree/activation-bug
  2. Run extension tests through the IDE without a dist folder
  3. Observe the stack trace which shows that VSCode is attempting to activate the extension from dist

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:5
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

0reactions
steadman1commented, Apr 12, 2021

a fresh install of node.js and vscode solved the issue for me

Read more comments on GitHub >

github_iconTop Results From Across the Web

VSCode: Tests won't proceed after using executeCommand to ...
openFolder command while a unit test is running is simply A Bad Thing to Do. I guess it somehow disrupts the connections between...
Read more >
Tests wont run from build output folder when using runsettings ...
I'm using msdn doc ms245570(v=vs. 110)which states to add a runsettings to solution then add the have this settings set to false ....
Read more >
Testing Extensions with Python — kit-manual 104.0 ...
An empty extension test entry is already an important one. Wrong or missing dependencies are a source of many future issues.
Read more >
Testing Extensions - Visual Studio Code
Visual Studio Code supports running and debugging tests for your extension. These tests will run inside a special instance of VS Code named...
Read more >
Configure SSL for the GitLab Linux package
To enable Let's Encrypt: Edit /etc/gitlab/gitlab.rb and add or change the following entries: ## GitLab instance external_url "https://gitlab.example.com" ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found