microsoft / microsoft/vscode-mssql

[Bug]: Query Profiler: "Extended Events session ... could not be found" even though the session exists and is running on the server

Open
#22,425 1 comment 0 reactions 1 assignee Claimed by @kburtram View on GitHub
Area - Query Profiler Bug User-filed
Dominant language
TypeScript
Stars
1.9k
Forks
610
Avg merge
2d 3h
Merged PRs (30d)
97

Description

### Description

Expected: Events start streaming into the grid.

Actual: Within ~10 seconds, the Output (MSSQL) channel logs:

[error] [Profiler] Session stopped with error: The Extended Events session named "" could not be found. Make sure the session exists and is started.
The error repeats (sometimes 3-4 duplicate lines with the identical timestamp), and recurs again automatically roughly every ~2 minutes without any further user action. The Start/Stop button states never update (Start stays enabled, Stop stays disabled), and the grid stays empty.

Independent verification that the session is NOT actually missing:

-- Run concurrently via sqlcmd/SSMS while the error is occurring:
SELECT name FROM sys.server_event_sessions WHERE name = ''; -- returns the session
SELECT name FROM sys.dm_xe_sessions WHERE name = ''; -- session is running
SELECT s.name, t.target_name
FROM sys.dm_xe_sessions s JOIN sys.dm_xe_session_targets t ON s.address = t.event_session_address
WHERE s.name = ''; -- target_name = 'ring_buffer', with real captured XML data
All three confirm the session exists, is running, and is actively capturing events — yet the extension reports it as not found.

What I've ruled out:

Permissions: login has sysadmin, is enabled.
Instance/name confusion: verified via SERVERPROPERTY('ProcessID') and TCP port ownership that only one matching SQL Server process answers on the connection used; a second, unrelated default instance on the same box has no TCP listener and is not involved.
Session-name collision: reproduces identically with a brand-new, never-before-used session name.
Stale extension state: reproduces even after fully closing the Profiler tab, manually ALTER EVENT SESSION ... STATE=STOP + DROP EVENT SESSION, and starting a completely fresh session.
Suspected cause: The existence check appears to go through SMO (XEStore.Sessions.Refresh() → indexer lookup, throwing SessionNotFound) rather than a direct DMV query — this may be failing to enumerate sessions correctly against this SQL Server build, even though raw T-SQL against sys.dm_xe_sessions / sys.server_event_sessions works fine.

### Steps to Reproduce

1. Connect to a local SQL Server named instance using a SQL login (not Windows auth).
2. Command Palette → "MSSQL: Launch Query Profiler".
3. New Session → template "Standard_OnPrem" (also reproduces with other templates/names) → enter a session name → Enter.
4. Click "Start".

### Affected Area

- [ ] Connection dialog (SQL Server | Azure browse/Fabric browse)
- [ ] Query editor
- [ ] Query results panel
- [ ] Object Explorer
- [ ] GitHub Copilot integration
- [ ] Preview/Edit data
- [ ] Table Designer
- [ ] Schema Designer
- [ ] Schema Compare
- [ ] Local SQL Server Container provisioning
- [ ] SQL database in Fabric provisioning
- [ ] DACPAC/BACPAC export/import
- [ ] SQL Database projects
- [ ] Query Plan Visualizer
- [x] Other (please describe below)

### If you selected "Other", please describe the affected area

Query Profiler

### Environment Information

- ms-mssql extension: 1.43.0
- VS Code: 1.127.0 (win32 x64)
- SQL Server: Microsoft SQL Server 2022 (RTM-GDR) 16.0.1180.1, Express Edition, KB5091158
- Connection: local named instance (localhost\), SQL Login auth (sa), sysadmin confirmed
- OS: Windows 11 Pro 10.0.26200

### Confirmation

- [x] I have searched existing issues and couldn't find a match
- [ ] I want to work on this issue

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.