Skip to content
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

[BUG]: exception when starting proxy from npm script #949

Open
waldekmastykarz opened this issue Dec 2, 2024 · 0 comments · May be fixed by #950
Open

[BUG]: exception when starting proxy from npm script #949

waldekmastykarz opened this issue Dec 2, 2024 · 0 comments · May be fixed by #950
Assignees
Labels
bug Something isn't working work in progress

Comments

@waldekmastykarz
Copy link
Collaborator

Description

When you start Dev Proxy from an npm script, you get an exception

Expected behaviour

Dev Proxy works just fine

Actual behaviour

npm start

> [email protected] start
> npx concurrently "npx http-server -p 3000 -s" "devproxy -c randomerror.devproxyrc.json"

[1]  info    GenericRandomErrorPlugin: 1 error responses loaded from /Users/waldek/github/pnp/proxy-samples/samples/demo-randomerror-js/devproxy-errors.json
[1]  info    Dev Proxy API listening on http://localhost:8897...
[1]  info    Dev Proxy listening on 127.0.0.1:8000...
[1] fail: Microsoft.Extensions.Hosting.Internal.Host[11]
[1]       Hosting failed to start
[1]       System.InvalidOperationException: Cannot see if a key has been pressed when either application does not have a console or when console input has been redirected from a file. Try Console.In.Peek.
[1]          at System.Console.get_KeyAvailable()
[1]          at Microsoft.DevProxy.ProxyEngine.ExecuteAsync(CancellationToken stoppingToken) in /Users/waldek/github/waldekmastykarz/dev-proxy/dev-proxy/ProxyEngine.cs:line 165
[1]          at Microsoft.Extensions.Hosting.Internal.Host.<StartAsync>b__14_1(IHostedService service, CancellationToken token)
[1]          at Microsoft.Extensions.Hosting.Internal.Host.ForeachService[T](IEnumerable`1 services, CancellationToken token, Boolean concurrent, Boolean abortOnFirstException, List`1 exceptions, Func`3 operation)
[1]  fail    An error occurred while running Dev Proxy Exception Details: System.InvalidOperationException: Cannot see if a key has been pressed when either application does not have a console or when console input has been redirected from a file. Try Console.In.Peek.
[1]    at System.Console.get_KeyAvailable()
[1]    at Microsoft.DevProxy.ProxyEngine.ExecuteAsync(CancellationToken stoppingToken) in /Users/waldek/github/waldekmastykarz/dev-proxy/dev-proxy/ProxyEngine.cs:line 165
[1]    at Microsoft.Extensions.Hosting.Internal.Host.<StartAsync>b__14_1(IHostedService service, CancellationToken token)
[1]    at Microsoft.Extensions.Hosting.Internal.Host.ForeachService[T](IEnumerable`1 services, CancellationToken token, Boolean concurrent, Boolean abortOnFirstException, List`1 exceptions, Func`3 operation)
[1]    at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
[1]    at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
[1]    at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
[1]    at Microsoft.DevProxy.CommandHandlers.ProxyCommandHandler.InvokeAsync(InvocationContext context) in /Users/waldek/github/waldekmastykarz/dev-proxy/dev-proxy/CommandHandlers/ProxyCommandHandler.cs:line 69
[1] Unhandled exception: System.InvalidOperationException: Cannot see if a key has been pressed when either application does not have a console or when console input has been redirected from a file. Try Console.In.Peek.
[1]    at System.Console.get_KeyAvailable()
[1]    at Microsoft.DevProxy.ProxyEngine.ExecuteAsync(CancellationToken stoppingToken) in /Users/waldek/github/waldekmastykarz/dev-proxy/dev-proxy/ProxyEngine.cs:line 165
[1]    at Microsoft.Extensions.Hosting.Internal.Host.<StartAsync>b__14_1(IHostedService service, CancellationToken token)
[1]    at Microsoft.Extensions.Hosting.Internal.Host.ForeachService[T](IEnumerable`1 services, CancellationToken token, Boolean concurrent, Boolean abortOnFirstException, List`1 exceptions, Func`3 operation)
[1]    at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
[1]    at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
[1]    at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
[1]    at Microsoft.DevProxy.CommandHandlers.ProxyCommandHandler.InvokeAsync(InvocationContext context) in /Users/waldek/github/waldekmastykarz/dev-proxy/dev-proxy/CommandHandlers/ProxyCommandHandler.cs:line 69
[1]    at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<<BuildInvocationChain>b__0>d.MoveNext()
[1] --- End of stack trace from previous location ---
[1]    at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass17_0.<<UseParseErrorReporting>b__0>d.MoveNext()
[1] --- End of stack trace from previous location ---
[1]    at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass12_0.<<UseHelp>b__0>d.MoveNext()
[1] --- End of stack trace from previous location ---
[1]    at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass22_0.<<UseVersionOption>b__0>d.MoveNext()
[1] --- End of stack trace from previous location ---
[1]    at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass19_0.<<UseTypoCorrections>b__0>d.MoveNext()
[1] --- End of stack trace from previous location ---
[1]    at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseSuggestDirective>b__18_0>d.MoveNext()
[1] --- End of stack trace from previous location ---
[1]    at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass16_0.<<UseParseDirective>b__0>d.MoveNext()
[1] --- End of stack trace from previous location ---
[1]    at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<RegisterWithDotnetSuggest>b__5_0>d.MoveNext()
[1] --- End of stack trace from previous location ---
[1]    at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass8_0.<<UseExceptionHandler>b__0>d.MoveNext()
[1] devproxy -c randomerror.devproxyrc.json exited with code 0
^C[0] npx http-server -p 3000 -s exited with code 0

Steps to reproduce

Run https://github.com/pnp/proxy-samples/tree/main/samples/demo-randomerror-js

Dev Proxy Version

v0.23.0

Operating system (environment)

macOS

Shell

zsh

Configuration file

https://github.com/pnp/proxy-samples/tree/main/samples/demo-randomerror-js

Additional Info

No response

@waldekmastykarz waldekmastykarz added the bug Something isn't working label Dec 2, 2024
@waldekmastykarz waldekmastykarz self-assigned this Dec 2, 2024
waldekmastykarz added a commit to waldekmastykarz/dev-proxy that referenced this issue Dec 2, 2024
waldekmastykarz added a commit to waldekmastykarz/dev-proxy that referenced this issue Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working work in progress
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant