Extension tests improperly activate instance from dist folder
See original GitHub issueI 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:
- Clone and checkout https://github.com/mpminardi/vscode-extension-samples/tree/activation-bug
- Run extension tests through the IDE without a
dist
folder - Observe the stack trace which shows that VSCode is attempting to activate the extension from
dist
Issue Analytics
- State:
- Created 4 years ago
- Reactions:5
- Comments:6 (1 by maintainers)
Top GitHub Comments
My suggestion reinstall npm and node: https://stackoverflow.com/questions/44363066/error-cannot-find-module-lib-utils-unsupported-js-while-using-ionic
a fresh install of node.js and vscode solved the issue for me