Closed
Description
Prerequisites
- I have written a descriptive issue title.
- I have searched all open and closed issues to ensure it has not already been reported.
- I have read the troubleshooting guide.
- I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
- I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
- If this is a security issue, I have read the security issue reporting guidance.
Summary
Hi,
Starting the VS Code extension with
"powershell.powerShellDefaultVersion": "Windows PowerShell (x64)"
causes the extension to crash, it works fine with PowerShell 7.2.6, but I need to use PowerShell 5.1 for certain legacy scripts.
This message appears in the terminal at startup. Similar to this issue here, but none of the resolutions for that thread worked. I have attempted to reinstall VS Code and the PowerShell extension but neither have worked. Additionally, I have another computer that has both VS Code and the extension installed and I cannot reproduce the error on it.
Exception encountered starting EditorServices. Exception logged in D:\a\_work\1\s\src\PowerShellEditorServices.Hosting\Commands\StartEditorServicesCommand.cs on line 238 in EndProcessing:
System.AggregateException: An error occurred while writing to logger(s). ---> DryIoc.ContainerException: code: Error.WaitForScopedServiceIsCreatedTimeoutExpired;
message: DryIoc has waited for the creation of the scoped or singleton service by the "other party" for the ticks without the completion.
You may call `exception.TryGetDetails(container)` to get the details of the problematic service registration.
The error means that either the "other party" is the parallel thread which has started but is unable to finish the creation of the service in the provided amount of time.
Or more likely the "other party" is the same thread and there is an undetected recursive dependency or
the scoped service creation is failed with the exception and the exception was catched but you are trying to resolve the failed service again.
For all those reasons DryIoc has a timeout to prevent the infinite waiting.
You may change the default timeout via `Scope.WaitForScopedServiceIsCreatedTimeoutTicks=NewNumberOfTicks`
at DryIoc.ContainerException.WithDetails(Object details, Int32 error, Object arg0, Object arg1, Object arg2, Object arg3)
at DryIoc.Scope.WaitForItemIsSet(ImMapEntry`1 itemRef)
at DryIoc.Factory.GetExpressionOrDefault(Request request)
at DryIoc.Container.ResolveAndCacheKeyed(Int32 serviceTypeHash, Type serviceType, Object serviceKey, IfUnresolved ifUnresolved, Object scopeName, Type requiredServiceType, Request preResolveParent, Object[] args)
at DryIoc.Container.DryIoc.IResolver.Resolve(Type serviceType, Object serviceKey, IfUnresolved ifUnresolved, Type requiredServiceType, Request preResolveParent, Object[] args)
at DryIoc.Interpreter.InterpretResolveMethod(IResolverContext resolver, IList`1 callArgs, Object paramExprs, Object paramValues, ParentLambdaArgs parentArgs, Boolean useFec, Object& result)
at DryIoc.Interpreter.TryInterpretMethodCall(IResolverContext r, Expression expr, Object paramExprs, Object paramValues, ParentLambdaArgs parentArgs, Boolean useFec, Object& result)
at DryIoc.Interpreter.TryInterpret(IResolverContext r, Expression expr, Object paramExprs, Object paramValues, ParentLambdaArgs parentArgs, Boolean useFec, Object& result)
at DryIoc.Interpreter.TryInterpretNestedLambdaBodyAndUnwrapException(IResolverContext r, Expression bodyExpr, Object paramExprs, Object paramValues, ParentLambdaArgs parentArgs, Boolean useFec)
at DryIoc.Interpreter.<>c__DisplayClass3_0.<TryInterpretNestedLambda>b__0()
at DryIoc.Interpreter.<>c__DisplayClass5_0`1.<ConvertFunc>b__0()
at System.Lazy`1.CreateValue()
at System.Lazy`1.LazyInitValue()
at OmniSharp.Extensions.JsonRpc.ResponseRouter.SendNotification[T](String method, T params)
at OmniSharp.Extensions.LanguageServer.Server.Logging.LanguageServerLogger.Log[TState](LogLevel logLevel, EventId eventId, TState state, Exception exception, Func`3 formatter)
at Microsoft.Extensions.Logging.Logger.<Log>g__LoggerLog|12_0[TState](LogLevel logLevel, EventId eventId, ILogger logger, Exception exception, Func`3 formatter, List`1& exceptions, TState& state)
--- End of inner exception stack trace ---
at Microsoft.Extensions.Logging.Logger.ThrowLoggingError(List`1 exceptions)
at Microsoft.Extensions.Logging.Logger.Log[TState](LogLevel logLevel, EventId eventId, TState state, Exception exception, Func`3 formatter)
at Microsoft.Extensions.Logging.Logger`1.Microsoft.Extensions.Logging.ILogger.Log[TState](LogLevel logLevel, EventId eventId, TState state, Exception exception, Func`3 formatter)
at Microsoft.Extensions.Logging.LoggerExtensions.Log(ILogger logger, LogLevel logLevel, EventId eventId, Exception exception, String message, Object[] args)
at OmniSharp.Extensions.JsonRpc.OutputHandler.<.ctor>b__13_3(Exception e)
at System.Reactive.Linq.ObservableImpl.Do`1.Actions._.OnError(Exception error)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Reactive.Stubs.<>c.<.cctor>b__2_1(Exception ex)
at System.Reactive.AnonymousSafeObserver`1.OnError(Exception error)
at System.Reactive.Sink`1.ForwardOnError(Exception error)
at System.Reactive.Linq.ObservableImpl.Do`1.Actions._.OnError(Exception error)
at System.Reactive.Sink`2.OnError(Exception error)
at System.Reactive.Linq.ObservableImpl.ThrowImmediate`1.Run(IObserver`1 observer)
at System.Reactive.BasicProducer`1.SubscribeRaw(IObserver`1 observer, Boolean enableSafeguard)
at System.Reactive.Linq.ObservableImpl.Defer`1._.Run()
at System.Reactive.Producer`2.SubscribeRaw(IObserver`1 observer, Boolean enableSafeguard)
at System.Reactive.Linq.ObservableImpl.Do`1.Actions.Run(_ sink)
at System.Reactive.Concurrency.Scheduler.<>c__75`1.<ScheduleAction>b__75_0(IScheduler _, ValueTuple`2 tuple)
at System.Reactive.Concurrency.CurrentThreadScheduler.Schedule[TState](TState state, TimeSpan dueTime, Func`3 action)
at System.Reactive.Concurrency.LocalScheduler.Schedule[TState](TState state, Func`3 action)
at System.Reactive.Concurrency.Scheduler.ScheduleAction[TState](IScheduler scheduler, TState state, Action`1 action)
at System.Reactive.Producer`2.SubscribeRaw(IObserver`1 observer, Boolean enableSafeguard)
at OmniSharp.Extensions.JsonRpc.OutputHandler..ctor(PipeWriter pipeWriter, ISerializer serializer, IEnumerable`1 outputFilters, IScheduler scheduler, ILogger`1 logger, IActivityTracingStrategy activityTracingStrategy)
at DryIoc.Interpreter.TryInterpretAndUnwrapContainerException(IResolverContext r, Expression expr, Boolean useFec, Object& result)
at DryIoc.Factory.ApplyReuse(Expression serviceExpr, Request request)
at DryIoc.Factory.GetExpressionOrDefault(Request request)
at DryIoc.FactoryMethod.<>c__DisplayClass10_0.<Constructor>b__0(Request request)
at DryIoc.ReflectionFactory.CreateExpressionOrDefault(Request request)
at DryIoc.Factory.GetExpressionOrDefault(Request request)
at DryIoc.ReflectionFactory.CreateExpressionOrDefault(Request request)
at DryIoc.Factory.GetExpressionOrDefault(Request request)
at DryIoc.Container.ResolveAndCache(Int32 serviceTypeHash, Type serviceType, IfUnresolved ifUnresolved)
at DryIoc.Container.DryIoc.IResolver.Resolve(Type serviceType, IfUnresolved ifUnresolved)
at DryIoc.Resolver.Resolve[TService](IResolver resolver, IfUnresolved ifUnresolved)
at OmniSharp.Extensions.LanguageServer.Server.LanguageServer.<From>d__37.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 Microsoft.PowerShell.EditorServices.Server.PsesLanguageServer.<StartAsync>d__14.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 Microsoft.PowerShell.EditorServices.Hosting.EditorServicesRunner.<CreateEditorServicesAndRunUntilShutdown>d__9.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 Microsoft.PowerShell.EditorServices.Commands.StartEditorServicesCommand.EndProcessing()
---> (Inner Exception #0) DryIoc.ContainerException: code: Error.WaitForScopedServiceIsCreatedTimeoutExpired;
message: DryIoc has waited for the creation of the scoped or singleton service by the "other party" for the ticks without the completion.
You may call `exception.TryGetDetails(container)` to get the details of the problematic service registration.
The error means that either the "other party" is the parallel thread which has started but is unable to finish the creation of the service in the provided amount of time.
Or more likely the "other party" is the same thread and there is an undetected recursive dependency or
the scoped service creation is failed with the exception and the exception was catched but you are trying to resolve the failed service again.
For all those reasons DryIoc has a timeout to prevent the infinite waiting.
You may change the default timeout via `Scope.WaitForScopedServiceIsCreatedTimeoutTicks=NewNumberOfTicks`
at DryIoc.ContainerException.WithDetails(Object details, Int32 error, Object arg0, Object arg1, Object arg2, Object arg3)
at DryIoc.Scope.WaitForItemIsSet(ImMapEntry`1 itemRef)
at DryIoc.Factory.GetExpressionOrDefault(Request request)
at DryIoc.Container.ResolveAndCacheKeyed(Int32 serviceTypeHash, Type serviceType, Object serviceKey, IfUnresolved ifUnresolved, Object scopeName, Type requiredServiceType, Request preResolveParent, Object[] args)
at DryIoc.Container.DryIoc.IResolver.Resolve(Type serviceType, Object serviceKey, IfUnresolved ifUnresolved, Type requiredServiceType, Request preResolveParent, Object[] args)
at DryIoc.Interpreter.InterpretResolveMethod(IResolverContext resolver, IList`1 callArgs, Object paramExprs, Object paramValues, ParentLambdaArgs parentArgs, Boolean useFec, Object& result)
at DryIoc.Interpreter.TryInterpretMethodCall(IResolverContext r, Expression expr, Object paramExprs, Object paramValues, ParentLambdaArgs parentArgs, Boolean useFec, Object& result)
at DryIoc.Interpreter.TryInterpret(IResolverContext r, Expression expr, Object paramExprs, Object paramValues, ParentLambdaArgs parentArgs, Boolean useFec, Object& result)
at DryIoc.Interpreter.TryInterpretNestedLambdaBodyAndUnwrapException(IResolverContext r, Expression bodyExpr, Object paramExprs, Object paramValues, ParentLambdaArgs parentArgs, Boolean useFec)
at DryIoc.Interpreter.<>c__DisplayClass3_0.<TryInterpretNestedLambda>b__0()
at DryIoc.Interpreter.<>c__DisplayClass5_0`1.<ConvertFunc>b__0()
at System.Lazy`1.CreateValue()
at System.Lazy`1.LazyInitValue()
at OmniSharp.Extensions.JsonRpc.ResponseRouter.SendNotification[T](String method, T params)
at OmniSharp.Extensions.LanguageServer.Server.Logging.LanguageServerLogger.Log[TState](LogLevel logLevel, EventId eventId, TState state, Exception exception, Func`3 formatter)
at Microsoft.Extensions.Logging.Logger.<Log>g__LoggerLog|12_0[TState](LogLevel logLevel, EventId eventId, ILogger logger, Exception exception, Func`3 formatter, List`1& exceptions, TState& state)<---
PowerShell Version
Name Value
---- -----
PSVersion 5.1.22621.169
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.22621.169
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Visual Studio Code Version
1.71.2
74b1f979648cc44d385a2286793c226e611f59e7
x64
Extension Version
ms-vscode.powershell@2022.8.5
Steps to Reproduce
- Open VS Code
- Make sure VS Code PowerShell extension is targeting 5.1
CTRL
+SHIFT
+P
and then type>PowerShell: Show Session Menu
- Extension will attempt to load and then throw the error in the description
- Extensions crashes and cannot be restarted until you exit VS Code
Visuals
No response
Logs
EditorServices.log
error.txt
ps_extension_output.txt
ps_editor_services_output.txt