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.

Inputting long values with Read-Host eventually triggers an exception

See original GitHub issue

System Details

System Details Output

### VSCode version: 1.47.2 17299e413d5590b14ab0340ea477cdd86ff13daf x64

### VSCode extensions:
ms-vscode.powershell-preview@2020.6.1

### Modules
I have PSReadLine 2.1.0 beta2 and it's checked in the extension settings

### PSES version: 2.2.0.0

### PowerShell version:

Name                           Value
----                           -----
PSVersion                      7.0.3
PSEdition                      Core
GitCommitId                    7.0.3
OS                             Microsoft Windows 10.0.19041
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Issue Description

Typing or pasting long values and submitting to Read-Host prompts eventually trigger a System.ArgumentOutOfRangeException

System.Exception: Prompt failed, check inner exception for details
 ---> System.ArgumentOutOfRangeException: The value must be greater than or equal to zero and less than the console's buffer size in that dimension. (Parameter 'top')
Actual value was 45.

This is related to #702

Expected Behaviour

The behavior should be consistent / no exception thrown

Actual Behaviour

I’ve observed that visually once the console output fills up the exception will be thrown on the next Read-Host try. Here’s a screencap I took. The first 2 runs of the script are fine but the 3rd throws the exception. If afterwards I run Clear-Host and try again it does not throw the exception. If I run Clear-Host before each script run (or include Clear-Host at the top of my script) I can consistently get it to behave correctly.

screencap

I also tried (instead of pasting values) seeing what would happen if I manually typed long values that wrap. It required me to do this many times until the height of the console output reached whatever height value this is – then the exception occurred.

screenshot

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
compelxcommented, Apr 5, 2022

Indeed, it’s been a while. I just tried to reproduce this and was unable to. Now if only the Azure PowerShell console didnt overwrite console output inline randomly… but I think we can close this one.

1reaction
SydneyhSmithcommented, Jul 28, 2020

Thanks @compelx looking at your stack trace, it looks like Read-Host is calling into a legacy version of our PSReadLine experience in the integrated terminal, we hope that we can resolve this as a part of the work happening in https://github.com/PowerShell/PowerShellEditorServices/issues/1295

Read more comments on GitHub >

github_iconTop Results From Across the Web

validate input from read-host using try-catch
guys, i am a newbie in powershell, could you help me in this,. i want the client to enter either 'y' or 'n',...
Read more >
Logging Exceptions in Java - Loggly
Logging can take place in the method where the exception occurred, or it can follow the exception up the call stack until it's...
Read more >
Exception Handling in Java - DigitalOcean
Introduction. An exception is an error event that can happen during the execution of a program and disrupts its normal flow.
Read more >
Understanding the Python Traceback
This code doesn't have any bugs that would result in an exception being raised as long as the right input is provided. If...
Read more >
Documentation: 15: 27.4. Hot Standby - PostgreSQL
We say that data on the standby is eventually consistent with the primary. ... Keep in mind however that a long-running query could...
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