Skip to content

Commit 8ee856f

Browse files
committed
Fix issues with progress stream in jobs
1 parent 39f42e1 commit 8ee856f

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/Common/Commands.Common/AzureLongRunningJob.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ protected AzureLongRunningJob(string command, string name) : base(command, name)
8080
/// <typeparam name="T">The type of the cmdlet being executed</typeparam>
8181
public class AzureLongRunningJob<T> : AzureLongRunningJob, ICommandRuntime where T : AzurePSCmdlet
8282
{
83+
const int MaxRecords = 1000;
8384
string _status = "Running";
8485
T _cmdlet;
8586
ICommandRuntime _runtime;
@@ -671,7 +672,7 @@ public bool TransactionAvailable()
671672
public void WriteCommandDetail(string text)
672673
{
673674
ThrowIfJobFailedOrCancelled();
674-
if (Verbose.IsOpen)
675+
if (Verbose.IsOpen && Verbose.Count < MaxRecords)
675676
{
676677
Verbose.Add(new VerboseRecord(text));
677678
}
@@ -684,7 +685,7 @@ public void WriteCommandDetail(string text)
684685
public void WriteDebug(string text)
685686
{
686687
ThrowIfJobFailedOrCancelled();
687-
if (Debug.IsOpen)
688+
if (Debug.IsOpen && Debug.Count < MaxRecords)
688689
{
689690
Debug.Add(new DebugRecord(text));
690691
}
@@ -745,7 +746,7 @@ public void WriteObject(object sendToPipeline, bool enumerateCollection)
745746
public void WriteProgress(ProgressRecord progressRecord)
746747
{
747748
ThrowIfJobFailedOrCancelled();
748-
if (Progress.IsOpen)
749+
if (Progress.IsOpen && Progress.Count < MaxRecords)
749750
{
750751
Progress.Add(progressRecord);
751752
}
@@ -769,7 +770,7 @@ public void WriteProgress(long sourceId, ProgressRecord progressRecord)
769770
public void WriteVerbose(string text)
770771
{
771772
ThrowIfJobFailedOrCancelled();
772-
if (Verbose.IsOpen)
773+
if (Verbose.IsOpen && Verbose.Count < MaxRecords)
773774
{
774775
Verbose.Add(new VerboseRecord(text));
775776
}

0 commit comments

Comments
 (0)