System.InvalidOperationException: Queue Empty when doing PSConsoleReadLine.ReadKey()

未关闭
#5,147 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
冷清
技术栈
csharp, powershell
领域
cli

调研方向

Start with the Microsoft.PowerShell.PSConsoleReadLine.ReadKey and InputLoop entries in the exception stack, focusing on the Queue.Dequeue call after compaction. Reproduce the listed PSReadLine 2.0.0 workflow in Windows Terminal, then verify that the first input no longer raises Queue empty.

由索引模型根据 Issue 内容生成。

描述

Needs-Triage :mag:
Prerequisites
  • Write a descriptive title.
  • Make sure you are able to repro it on the latest released version
  • Search the existing issues, especially the pinned issues.
Exception report
[DBG]: PS C:\MtiFilm\dev\SANDBOX-B>> I don't u
Oops, something went wrong.  Please report this bug with the details below.
Report on GitHub: https://github.com/PowerShell/PSReadLine/issues/new
### Environment
PSReadLine: 2.0.0
PowerShell: 5.1.26100.8457
OS: Microsoft Windows 10.0.26200
Last 69 Keys

 / c o l o r Enter
 c l a u s d Backspace Backspace d e Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace c e Spacebar Backspace Backspace d Spacebar \ m t i f Tab d e v Tab s Tab Tab Tab Shift+Tab Enter
 c l a u d e Enter
 I Spacebar d o n ' t Spacebar u


### Exception

System.InvalidOperationException: Queue empty.
   at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
   at System.Collections.Generic.Queue`1.Dequeue()
   at Microsoft.PowerShell.PSConsoleReadLine.ReadKey()
   at Microsoft.PowerShell.PSConsoleReadLine.InputLoop()
   at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics, CancellationToken cancellationToken)


[DBG]: PS C:\MtiFilm\dev\SANDBOX-B>>
Oops, something went wrong.  Please report this bug with the details below.
Report on GitHub: https://github.com/PowerShell/PSReadLine/issues/new
### Environment
PSReadLine: 2.0.0
PowerShell: 5.1.26100.8457
OS: Microsoft Windows 10.0.26200
Last 80 Keys

 / c o l o r Enter
 c l a u s d Backspace Backspace d e Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace c e Spacebar Backspace Backspace d Spacebar \ m t i f Tab d e v Tab s Tab Tab Tab Shift+Tab Enter
 c l a u d e Enter
 I Spacebar d o n ' t Spacebar u n d e r s t a n s d Escape


### Exception

System.InvalidOperationException: Queue empty.
   at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
   at System.Collections.Generic.Queue`1.Dequeue()
   at Microsoft.PowerShell.PSConsoleReadLine.ReadKey()
   at Microsoft.PowerShell.PSConsoleReadLine.InputLoop()
   at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics, CancellationToken cancellationToken)
Screenshot
Image
Environment data
PS Version: 5.1.26100.8457
PS HostName: ConsoleHost (Windows Terminal)
PSReadLine Version: 2.0.0
PSReadLine EditMode: Windows
OS: 10.0.26100.1 (WinBuild.160101.0800)
BufferWidth: 120
BufferHeight: 61
Steps to reproduce

Randomly crashe on my first input after a compaction

Expected behavior

No exception

Actual behavior

The above exception happened. then when I tried to resume the conversation, I got this:

[DBG]: PS C:\MtiFilm\dev\SANDBOX-B>> claude --resume 1251e8d7-aaf0-45e2-8604-dff9aa3c8475
claude : Error: No deferred tool marker found in the resumed session. Either the session was not deferred, the marker
is stale (tool already ran), or it exceeds the tail-scan window. Provide a prompt to continue the conversation.
At line:1 char:1

  • claude --resume 1251e8d7-aaf0-45e2-8604-dff9aa3c8475
  •   + CategoryInfo          : NotSpecified: (Error: No defer...e conversation.:String) [], RemoteException
      + FullyQualifiedErrorId : NativeCommandError
主要语言
C#
星标
4.4k
派生
341
PR 合并指标
30 天内没有已合并 PR

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

PowerShell/PSReadLine 的其他 Issue

查看 PowerShell/PSReadLine 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。