Skip to content

Conversation

@mkrueger
Copy link
Member

@mkrueger mkrueger commented Nov 25, 2025

image

This pull request improves the reliability and user experience of reading documents in Cosmos DB by adding timeout handling, fallback logic, and clearer error messaging. The changes ensure that if a document read operation fails or times out, a fallback query by _rid is attempted, and users receive a more informative error message in the UI when a document cannot be found or retrieved.

Error Handling and Messaging Improvements:

  • Added a new localized error message "Item not found or request timed out" to bundle.l10n.json for clearer user feedback when document retrieval fails.
  • Updated the error reporting in DocumentSession.read to send a documentError event with the new message when a document cannot be found or read, instead of sending a generic or query error.

Timeouts and Fallback Logic:

  • Implemented a 4-second timeout for both the primary document read and the fallback _rid query in DocumentSession, with appropriate logging and error handling for timeouts. [1] [2] [3]
  • Added fallback logic: if the primary read fails or times out, a secondary query by _rid is attempted, and detailed logs are generated based on the results.

UI Improvements:

  • Enhanced the document panel UI to display a loading state only when appropriate, and to show a user-friendly error message when a document cannot be loaded, such as when it is deleted externally or a timeout occurs.

Fixes #2822

@mkrueger mkrueger requested a review from a team as a code owner November 25, 2025 14:23
sevoku
sevoku previously approved these changes Nov 26, 2025
bk201-
bk201- previously approved these changes Nov 27, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request addresses issue #2822 where opening a deleted Cosmos DB item causes indefinite loading. The changes implement timeout handling for document read operations, add fallback logic using _rid queries, and improve error messaging in the UI.

Key Changes

  • Added 4-second timeout for document read operations with fallback to _rid query if primary read fails
  • Introduced documentError event messaging to properly communicate read failures to the UI instead of using generic query errors
  • Enhanced UI to display user-friendly error messages when documents cannot be loaded due to deletion or timeout

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
l10n/bundle.l10n.json Added localized error message "Item not found or request timed out" for clearer user feedback
src/webviews/cosmosdb/Document/DocumentPanel.tsx Updated loading/error state logic to show appropriate UI when document cannot be loaded
src/cosmosdb/session/DocumentSession.ts Implemented timeout handling with Promise.race, added fallback _rid query, and changed error reporting to use documentError events

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI commented Dec 3, 2025

@mkrueger I've opened a new pull request, #2858, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI commented Dec 4, 2025

@mkrueger I've opened a new pull request, #2864, to work on those changes. Once the pull request is ready, I'll request review from you.

@mkrueger mkrueger force-pushed the dev/mkrueger/issue2822 branch from 4d8bd43 to 07ee96f Compare December 4, 2025 10:57
Added timeout & error message.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +255 to +261
await this.channel.postMessage({
type: 'event',
name: 'documentError',
params: [this.id, errorMessage],
});
// Still log telemetry but don't use errorHandling which sends queryError
context.telemetry.properties.error = errorMessage;
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The telemetry properties are set after the documentError event is sent, which means the error information won't be included in the telemetry context that gets logged. This telemetry assignment should happen before the postMessage call to ensure the error details are captured in the telemetry.

Suggested change
await this.channel.postMessage({
type: 'event',
name: 'documentError',
params: [this.id, errorMessage],
});
// Still log telemetry but don't use errorHandling which sends queryError
context.telemetry.properties.error = errorMessage;
// Still log telemetry but don't use errorHandling which sends queryError
context.telemetry.properties.error = errorMessage;
await this.channel.postMessage({
type: 'event',
name: 'documentError',
params: [this.id, errorMessage],
});

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Opening a deleted Item loads indefinitely

4 participants