microsoft / microsoft/vscode-mssql
[Bug]: Query editor stays active after database is deleted and later reports 'Query was canceled by user'
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.9k
- Forks
- 610
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 97
Description
### Description
If a query editor is connected to a database and that database is deleted through the drop/delete dialog, the existing query editor session can still start query execution. After some time, the query finishes with:
`Query was canceled by user`
That message is incorrect because the user did not cancel the query. Once the target database has been deleted, the query editor should detect that its database context is no longer valid and fail immediately with a clear error.
This appears related to the Azure Data Studio issue https://github.com/microsoft/azuredatastudio/issues/23661, but in vscode-mssql the observable behavior is that execution starts and later ends with an incorrect cancellation message.
Observed message output:
- Started executing query at Line 1
- Query was canceled by user
- Total execution time: 00:00:10.039
### Steps to Reproduce
1. Connect a query editor to a user database.
2. Run a query successfully against a user table to confirm the editor is using that database.
3. In Object Explorer, delete that database through the drop/delete dialog.
4. Return to the already-open query editor for that database.
5. Run the same query again.
### Expected Behavior
The extension should detect that the database no longer exists and:
- fail immediately with a clear error that the database was deleted or is no longer available
- not report `Query was canceled by user` unless the user actually canceled the query
- reset or invalidate the query editor session so the user can reconnect to a valid database
### Actual Behavior
The query is allowed to start, then after some delay it completes with:
- `Query was canceled by user`
This leaves the user with a misleading message instead of a clear database-context failure.
### Affected Area
- Query editor
- Query results panel
- Object Explorer / query session interaction after database deletion
### Environment Information
- VS Code Version: [fill in]
- MSSQL Extension Version: [fill in]
- Operating System: Windows
- Connection Type: SQL Server
- Database removal method: Drop/Delete dialog in Object Explorer
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the query editor execution path and its interaction with Object Explorer's drop/delete dialog, then reproduce the failure using the steps in this issue. Trace how the query results panel handles a deleted database and distinguish that failure from user cancellation. Done means execution fails immediately with a clear database-unavailable error and the session is reset or invalidated.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- sql, typescript
- Domain
- database
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100