Repository navigation
StdErr is wrapped as ErrorRecord producing undesired effects #3813
Copy link
Copy link
Closed
Labels
Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.The issue is fixed.WG-Interactive-Consolethe console experiencethe console experience
Milestone
Description
Steps to reproduce
Run some executable that outputs a long line to stderr and redirect it.
For example
python -c "from __future__ import print_function`nimport sys`nprint(range(100), file=sys.stderr)" *> 1
Real-life scenario that's highly impacted by that problem is searching in the logs.
When log file can be arbitrary split on the search tokens, you cannot reliable find anything in the logs.
Expected behavior
One line in the file 1
Actual behavior
Several lines in the output file.
Compare it with the redirection of stdout which works as expected.
PS /Users/svorobev/junk> python -c "from __future__ import print_function`nimport sys`nprint(range(100), file=sys.stdout)" *> 1
PS /Users/svorobev/junk> cat 1 | measure
Count : 1
Average :
Sum :
Maximum :
Minimum :
Property :
PS /Users/svorobev/junk> python -c "from __future__ import print_function`nimport sys`nprint(range(100), file=sys.stderr)" *> 1
PS /Users/svorobev/junk> cat 1 | measure
Count : 3
Average :
Sum :
Maximum :
Minimum :
Property :
Environment data
> $PSVersionTable
Name Value
---- -----
PSVersion 6.0.0-beta
PSEdition Core
BuildVersion 3.0.0.0
CLRVersion
GitCommitId v6.0.0-beta.1
OS Darwin 16.6.0 Darwin Kernel Version 16.6.0: Fri Apr 14 16:21:16 PDT 2017; root:xnu-3789.60.24~6/RELEASE_X86_64
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0 Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.The issue is fixed.WG-Interactive-Consolethe console experiencethe console experience
Activity
vors commentedon Jun 3, 2017
I looked into that, the gist of the problem is the following
In GenerateOutOfBandData we are receiving View for error record, which is registered here.
If we receive a View, it's automatically will be passed thru out format system, either as a complex object or as a list. That would force the screen width formatting on it.
There are few ways we can go about it that come to my mind:
Looking for opinions
SteveL-MSFT commentedon Jun 3, 2017
Seems like option 3 is best. Whenever PowerShell works with native cmds we should keep the data raw for perf and compat reasons.
iSazonov commentedon Jun 4, 2017
Can the problem be in other streams?
Can the problem will be resolved by native pipes #1908?
iSazonov commentedon Jun 5, 2017
I can't reproduce the bug with cmd.exe instead of python 😕
vors commentedon Jun 5, 2017
Ilya (@iSazonov) you may need to make your window smaller or output larger to observe it (essentially larger then 1 width of your window)
Here is another repro with just powershell
iSazonov commentedon Jun 5, 2017
Thanks for the repo!
I see that the formatting work well - we hit that line.
If we remove the view the problem persists.
So the problem is somewhere else.
iSazonov commentedon Jun 5, 2017
Maybe be the same problem #1491
vors commentedon Jun 5, 2017
Let me elaborate the problem.
If
view != nullhereWe are using ViewGenerator and it will apply logic for the window width.
What we want is something like GenerateOutOfBandObjectAsToString(so)
iSazonov commentedon Jun 6, 2017
Thanks for clarify!
Can we add new parameter in the view?
CustomControl.Create(outOfBand: true, MaxWidth: Int.MaxValue)[-]Redirecting stderr adds extra-line breaks[/-][+]StdErr is wrapped as ErrorRecord producing undesired effects[/+]daxian-dbw commentedon Nov 28, 2017
Steve Lee (@SteveL-MSFT) Is this issue already fixed? The PR #5190 hasn't been merged, but I cannot repro with sergei (@vors)'s windows repro step on RC build:
SteveL-MSFT commentedon Nov 29, 2017
Dongbo Wang (@daxian-dbw) the original issue where line breaks were added at window width has been fixed. stderr is still being wrapped as error record, but it gets unwrapped I believe so it's just an optimization. I think we can close this since the original user facing issue is resolved.
vors commentedon Nov 30, 2017
Oh nice, didn't see that coming 💃