aws / aws/aws-toolkit-vscode

PriorityQueue is not a constructor causes chat history trimming to fail, leading to unbounded file growth and language server crash

Open
#8,704 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
2k
Forks
807
Avg merge
10h 12m
Merged PRs (30d)
7

Description

The chat history trimming logic fails silently with a TypeError: o.PriorityQueue is not a constructor error. Because trimming never succeeds, the history file grows without bound. Once it exceeds Node.js's string length limit, JSON.stringify throws RangeError: Invalid string length, which crashes the language server entirely and causes all conversation context to be lost.

Steps to reproduce:

Use Amazon Q in VS Code without an open workspace over an extended period

Observe chat-history-no-workspace.json growing past the 209MB limit

Language server begins crashing on every session start

Errors observed in logs:

Current history total size: 537583857 Bytes, max allowed: 209715200 Bytes
History total size exceeds limit, trimming history
Error trimming history: TypeError: o.PriorityQueue is not a constructor
RangeError: Invalid string length (at JSON.stringify)
Failed to migrate agent config: Unexpected end of JSON input

Copy
Expected behavior:

History trimming should successfully reduce file size when the limit is exceeded

The language server should not crash due to an oversized history file

Actual behavior:

PriorityQueue is not correctly imported/instantiated in the trimming code

History file grew to 537MB (2.5x the 209MB limit)

Language server crashes repeatedly, losing all conversation context

Environment:

Extension: Amazon Q for VS Code

OS: Windows

History file affected: %USERPROFILE%\.aws\amazonq\history\chat-history-no-workspace.json

Workaround:
Manually delete or clear chat-history-no-workspace.json and replace agents/default.json with {}.

## Steps to reproduce the issue

## Expected behavior

## System details (run `AWS: About` and/or `Amazon Q: About`)

- OS:
- Visual Studio Code version:
- AWS Toolkit version:
- Amazon Q version:

Contributor guide

Open the contributing guide

Research direction

Start with the chat-history-no-workspace.json growth and the logged PriorityQueue constructor error, then locate the history trimming implementation in the extension. Reproduce the over-limit condition and verify that trimming reduces the history file below the limit without crashing the language server or losing conversation context.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
developer-experience
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.