vscode icon indicating copy to clipboard operation
vscode copied to clipboard

Executing commands in n pwsh in parallel can cause problems with history

Open dbaeumer opened this issue 1 year ago • 1 comments

Testing #226655

Got the following error when executing commands in two pwsh processes in parallel

Error reading or writing history file 'C:\xxx\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadline\ConsoleHost_history.txt': The process cannot access the file 'C:\xxx\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadline\ConsoleHost_history.txt' because it is being used by another process.

I could build my own queue and use start / stop events to drain the queue. But may be a waitUntilDone(): Promise<number> on the TerminalShellExecution returned from executeCommand would ease that.

dbaeumer avatar Aug 28 '24 07:08 dbaeumer

@dbaeumer was this in the terminal (pwsh's problem) or in devtools (our problem)?

Tyriar avatar Aug 28 '24 14:08 Tyriar

I tested https://github.com/microsoft/vscode/issues/226655 and executed two commands using TerminalShellIntegration#executeCommand. The two pwsh shells execute them in parallel and both try to modify the history. It is not necessarily a bug in our code, however it is not easy to synchronize the execution with the API we provide.

dbaeumer avatar Aug 29 '24 07:08 dbaeumer

@dbaeumer I mean do you see the error printed in the terminal or in the debugger/devtools console? If it's the former it would be a bug I need to report to the powershell team.

Tyriar avatar Aug 29 '24 12:08 Tyriar

@Tyriar I see the problem printed in the terminal.

dbaeumer avatar Aug 30 '24 07:08 dbaeumer

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!

In that case it's that powershell isn't good at dealing with multiple writes to the history file. fyi @daxian-dbw

Tyriar avatar Sep 06 '24 15:09 Tyriar