Skip to content

Extension doesn't start up when files.exclude values are non-boolean #2658

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

Closed
BooTheHamster opened this issue Apr 24, 2020 · 16 comments · Fixed by PowerShell/PowerShellEditorServices#1726

Comments

@BooTheHamster
Copy link

BooTheHamster commented Apr 24, 2020

Powershell integrated console hangs on when I open powershel source file. Running any powershell code by pressing F5 also hangs on.

Attach output console log, terminal window screenshot and logs.
ms-vscode.powershell-logs.zip
terminal-window-log.txt
vscode-output-log.txt
vscode-terminal-window

@ghost ghost added the Needs: Triage Maintainer attention needed! label Apr 24, 2020
@TylerLeonhardt
Copy link
Member

Do you have any privilege management software or antivirus software installed on this machine? We've heard reports that these slow down start up...

@TylerLeonhardt TylerLeonhardt added Needs-Repro-Info and removed Needs: Triage Maintainer attention needed! labels Apr 24, 2020
@BooTheHamster
Copy link
Author

No.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Apr 24, 2020
@SydneyhSmith
Copy link
Collaborator

@BooTheHamster thanks for the logs could you please also provide any settings you have in vscode?

@SydneyhSmith SydneyhSmith removed the Needs: Maintainer Attention Maintainer attention needed! label Apr 28, 2020
@BooTheHamster
Copy link
Author

BooTheHamster commented Apr 29, 2020

PS C:\Work\bin> code --list-extensions
adrianwilczynski.namespace
alefragnani.numbered-bookmarks
christian-kohler.path-intellisense
cyrilletuzi.angular-schematics
dawidd6.debian-vscode
dsznajder.es7-react-js-snippets
edag94.replacequotes
eternalphane.tsfmt-vscode
fknop.vscode-npm
heaths.vscode-guid
jchannon.csharpextensions
jmrog.vscode-nuget-package-manager
k--kato.docomment
Mikael.Angular-BeastCode
mike-co.import-sorter
MikeBovenlander.formate
ms-dotnettools.csharp
ms-python.python
ms-vscode-remote.remote-containers
ms-vscode-remote.remote-ssh
ms-vscode-remote.remote-ssh-edit
ms-vscode-remote.remote-wsl
ms-vscode-remote.vscode-remote-extensionpack
ms-vscode.powershell
ms-vscode.vscode-typescript-tslint-plugin
msjsdiag.debugger-for-chrome
Shan.code-settings-sync
steoates.autoimport
vscode-icons-team.vscode-icons
wayou.vscode-todo-highlight
zhouronghui.propertylist
Zignd.html-css-class-completion

settings.txt

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Apr 29, 2020
@TylerLeonhardt
Copy link
Member

@BooTheHamster can you explain this line in your settings?

"**/*.js": { "when": "$(basename).ts"} in files.exclude...

I think if you remove that, you won't see this issue.

@rjmholt
Copy link
Contributor

rjmholt commented Apr 29, 2020

Looks like this is an (as far as I can tell) undocumented but used syntax. In order to accommodate it we'll need to either make parsing it fail nicely or implement a custom JSON parser for it

@BooTheHamster
Copy link
Author

can you explain this line in your settings?

Old settings to hide *.js files when correcponding *.ts file exists.

@TylerLeonhardt thanks, I remove this settings and issue gone.

@TylerLeonhardt TylerLeonhardt changed the title PowerShell Integrated Console Hangs Extension doesn't start up when files.exclude values are non-boolean Apr 29, 2020
@TylerLeonhardt
Copy link
Member

I've reopened this to track us handling this setting better.

@conscribtor
Copy link

I'm running into this issue as well when using the following settings:

    "files.exclude": {
        "**/__pycache__": true,
        "**/*.pyc": {
            "when": "$(basename).py"
        }
    },

Since it's just a QOL setting, I've removed it to make it work.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Sep 12, 2020
@SydneyhSmith SydneyhSmith removed the Needs: Maintainer Attention Maintainer attention needed! label Sep 15, 2020
@YipYipX4
Copy link

I also get the failure with the following files.exclude settings:

    "files.exclude": {
        "**/*.pyc": {"when": "$(basename).py"}, 
        "**/__pycache__": true
    },

The first of those settings will hide compiled Python 2 output files as long as the corresponding *.py file is present (but if you delete or rename the original file, then the *.pyc file will show up in the File Explorer pane). The second of those settings hides the directory where Python 3 compiled output is stored.

Below are the exception and call stack reported in the PowerShell Editor Services output pane. Looks like the problem might originate near ConfigurationHandler.cs line 52?

[Error - 1:56:34 PM] OmniSharp.Extensions.JsonRpc.InputHandler: Failed to handle request workspace/didChangeConfiguration - Newtonsoft.Json.JsonReaderException: Error reading boolean. Unexpected token: StartObject. Path 'files.exclude['**/*.pyc']'.
at Newtonsoft.Json.JsonReader.ReadAsBoolean()
at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateDictionary(IDictionary dictionary, JsonReader reader, JsonDictionaryContract contract, JsonProperty containerProperty, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType, JsonSerializer jsonSerializer)
at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType)
at Newtonsoft.Json.Linq.JToken.ToObjectT
at Microsoft.PowerShell.EditorServices.Handlers.PsesConfigurationHandler.Handle(DidChangeConfigurationParams request, CancellationToken cancellationToken) in D:\a\1\s\src\PowerShellEditorServices\Services\Workspace\Handlers\ConfigurationHandler.cs:line 52
at MediatR.Pipeline.RequestExceptionProcessorBehavior2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate1 next)
at MediatR.Pipeline.RequestExceptionProcessorBehavior2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate1 next)
at MediatR.Pipeline.RequestExceptionActionProcessorBehavior2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate1 next)
at MediatR.Pipeline.RequestExceptionActionProcessorBehavior2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate1 next)
at MediatR.Pipeline.RequestPostProcessorBehavior2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate1 next)
at MediatR.Pipeline.RequestPreProcessorBehavior2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate1 next)
at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate1 next)
at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.RouteNotification(TDescriptor descriptor, Notification notification, CancellationToken token)
at OmniSharp.Extensions.JsonRpc.InputHandler.<>c__DisplayClass39_0.<b__4>d.MoveNext() | Method='workspace/didChangeConfiguration'

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Nov 13, 2020
@TylerLeonhardt
Copy link
Member

Thanks for the extra info. We have a good idea where the problem is:

https://github.com/PowerShell/PowerShellEditorServices/blob/03373ae00cf1730da48d31cfa4c48c359d2952b1/src/PowerShellEditorServices/Services/Workspace/LanguageServerSettings.cs#L407-L431

See the use of Dictionary<string, bool>... that doesn't get deserialized correctly when we get "**/*.pyc": {"when": "$(basename).py"}

Not sure if @david-driscoll has any ideas here on the best way to handle this... but we probably need this to be a Dictionary of <string, BoolOrWhen> where BoolOrWhen is a class:

class BoolOrWhen
{
    public bool HasBool => _boolValue != null;
    private bool? _boolValue;
    public bool Bool => _boolValue ?? false;
    
    public bool HasWhen => When != null;
    public string When { get; private set; }
}

and then we have a Newtonsoft serializer that will handle turning what's given into this class.

With all that said... we've got a lot on our plate right now so this isn't the highest priority issue, unfortunately. If someone wants to help out and pick this up, we can probably be able to assist in walking through this.

@TylerLeonhardt TylerLeonhardt added Up for Grabs Will shepherd PRs. and removed Needs: Maintainer Attention Maintainer attention needed! labels Nov 16, 2020
@austindimmer
Copy link

I observed this issue today and spent a few hours trying to get my debugger to connect.

I modifed settings.json from:

{
  "files.exclude": {
    "amplify/.config": true,
    "amplify/**/*-parameters.json": true,
    "amplify/**/amplify.state": true,
    "amplify/**/transform.conf.json": true,
    "amplify/#current-cloud-backend": true,
    "amplify/backend/amplify-meta.json": true,
    "amplify/backend/awscloudformation": true,
    "**/.git": true,
    "**/.DS_Store": true,
    "**/*.js": {
      "when": "$(basename).ts"
    },
    "**/*.d.ts": {
      "when": "$(basename).ts"
    }
  },
  "deepscan.enable": true,
  "editor.codeActionsOnSave": {
    "source.fixAll.markdownlint": true,
    "source.fixAll.eslint": true
  }
}

to (commenting out the causative issue)

{
  "files.exclude": {
    "amplify/.config": true,
    "amplify/**/*-parameters.json": true,
    "amplify/**/amplify.state": true,
    "amplify/**/transform.conf.json": true,
    "amplify/#current-cloud-backend": true,
    "amplify/backend/amplify-meta.json": true,
    "amplify/backend/awscloudformation": true,
    "**/.git": true,
    "**/.DS_Store": true,
    // "**/*.js": {
    //   "when": "$(basename).ts"
    // },
    // "**/*.d.ts": {
    //   "when": "$(basename).ts"
    // }
  },
  "deepscan.enable": true,
  "editor.codeActionsOnSave": {
    "source.fixAll.markdownlint": true,
    "source.fixAll.eslint": true
  }
}

My logs (EditorServices.log) whilst this was broken looked like follows

2021-02-26 11:26:12.706 +01:00 [INF] PowerShell runtime version: 5.1.19041.610, edition: Desktop
2021-02-26 11:26:13.446 +01:00 [INF] highlight handler loaded
2021-02-26 11:26:13.980 +01:00 [ERR] Execution of the following command(s) completed with errors:
    Import-Module ~\.vscode\extensions\ms-vscode.powershell-2021.2.2\modules\PowerShellEditorServices\Commands\PowerShellEditorServices.Commands.psd1

2021-02-26 11:26:14.892 +01:00 [FTL] Failed to handle request workspace/didChangeConfiguration
Newtonsoft.Json.JsonReaderException: Error reading boolean. Unexpected token: StartObject. Path 'files.exclude['**/*.js']'.
   at Newtonsoft.Json.JsonReader.ReadAsBoolean()
   at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateDictionary(IDictionary dictionary, JsonReader reader, JsonDictionaryContract contract, JsonProperty containerProperty, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType, JsonSerializer jsonSerializer)
   at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType)
   at Newtonsoft.Json.Linq.JToken.ToObject[T]()
   at Microsoft.PowerShell.EditorServices.Handlers.PsesConfigurationHandler.<Handle>d__11.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.SemanticTokensDeltaPipeline`2.<Handle>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline`2.<Handle>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at MediatR.Pipeline.RequestPreProcessorBehavior`2.<Handle>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at MediatR.Pipeline.RequestPostProcessorBehavior`2.<Handle>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.<Handle>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.<Handle>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.<Handle>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.<Handle>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.<<RouteNotification>g__InnerRoute|4_1>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.<RouteNotification>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at OmniSharp.Extensions.JsonRpc.InputHandler.<>c__DisplayClass39_0.<<RouteNotification>b__3>d.MoveNext()
2021-02-26 11:26:15.880 +01:00 [INF] PSScriptAnalyzer settings file not found. Falling back to default rules

And when fixed

2021-02-26 15:30:02.604 +01:00 [INF] PowerShell runtime version: 7.1.2, edition: Core
2021-02-26 15:30:02.931 +01:00 [INF] highlight handler loaded
2021-02-26 15:30:03.405 +01:00 [ERR] Execution of the following command(s) completed with errors:

    Import-Module ~.vscode\extensions\ms-vscode.powershell-preview-2021.2.1\modules\PowerShellEditorServices\Commands\PowerShellEditorServices.Commands.psd1


2021-02-26 15:30:04.639 +01:00 [INF] Unable to find PSSA settings file at 'c:\PSScriptAnalyzerSettings.psd1'. Loading default rules.
2021-02-26 15:30:04.645 +01:00 [INF] PSScriptAnalyzer settings file not found. Falling back to default rules

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Feb 26, 2021
@rjmholt
Copy link
Contributor

rjmholt commented Feb 26, 2021

I've finally tracked down the definition of this expression syntax. As far as I know it's still undocumented and it's not clear how stable this is intended to be, but we might at least be able to implement something around it given this information.

@andyleejordan andyleejordan added this to the Consider-vNext milestone Feb 26, 2021
@TylerLeonhardt
Copy link
Member

It's a stable API. It's just... unfortunately... not documented.

@SydneyhSmith SydneyhSmith removed the Needs: Maintainer Attention Maintainer attention needed! label Mar 2, 2021
@haugerbr
Copy link

haugerbr commented Apr 5, 2021

It's documented here on the official VSCode docs. Unless we are talking about it being documented somewhere else?

@andyleejordan
Copy link
Member

The fix for this is out in PowerShell Preview v2022.2.2!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

9 participants