Skip to content

Refactor HTTP request handling for improved resource management and error handling#5296

Merged
gautamdsheth merged 4 commits intodevfrom
feat/improve-concurrency
Apr 22, 2026
Merged

Refactor HTTP request handling for improved resource management and error handling#5296
gautamdsheth merged 4 commits intodevfrom
feat/improve-concurrency

Conversation

@gautamdsheth
Copy link
Copy Markdown
Collaborator

Before creating a pull request, make sure that you have read the contribution file located at

https://github.com/pnp/powerShell/blob/dev/CONTRIBUTING.md

Type

  • Bug Fix
  • New Feature
  • Sample

Related Issues?

Fixes #X, partially fixes #Y, mentioned in #Z, etc.

What is in this Pull Request ?

Please describe the changes in the PR.

Guidance

  • You can delete this section when you are submitting the pull request.*
  • Please update this PR information accordingly. We use this as part of our release notes in monthly communications.
  • Please target your PR to Dev branch. If you do not target the Dev branch we will not accept this PR.

Copilot AI review requested due to automatic review settings April 21, 2026 19:43
Copy link
Copy Markdown
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 PR refactors several HTTP/process handling call sites to improve resource management (disposing requests/responses/processes) and centralize request construction/serialization behavior across the module.

Changes:

  • Refactors version checking HTTP calls to use a shared helper with cancellation-based timeout and proper disposal.
  • Refactors REST helper methods to build per-request HttpRequestMessage objects (instead of mutating HttpClient.DefaultRequestHeaders) and reuses shared JsonSerializerOptions.
  • Ensures HttpResponseMessage / Process objects are disposed in multiple call sites (Graph invoke methods, unified audit log paging, shell runner).

Reviewed changes

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

Show a summary per file
File Description
src/Commands/Utilities/VersionChecker.cs Introduces a helper to fetch version check content with cancellation timeout + disposals.
src/Commands/Utilities/Shell.cs Disposes the created Process via using var.
src/Commands/Utilities/REST/RestHelper.cs Moves header/auth to per-request messages; reuses serializer options; adds helper to apply additional headers.
src/Commands/Utilities/CmdletMessageWriter.cs Makes queue access thread-safe via locking and simplifies dequeue logic.
src/Commands/ManagementApi/GetUnifiedAuditLog.cs Fixes URL interpolation and disposes paged HTTP responses reliably.
src/Commands/Graph/InvokeGraphMethod.cs Disposes responses for POST/PUT/PATCH/DELETE helpers via using var.

Comment thread src/Commands/Utilities/REST/RestHelper.cs
Co-authored-by: Copilot <copilot@github.com>
Copy link
Copy Markdown
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 6 out of 6 changed files in this pull request and generated 7 comments.

Comment thread src/Commands/Utilities/REST/RestHelper.cs Outdated
Comment thread src/Commands/Utilities/REST/RestHelper.cs Outdated
Comment thread src/Commands/Utilities/REST/RestHelper.cs Outdated
Comment thread src/Commands/Utilities/VersionChecker.cs
Comment thread src/Commands/Utilities/REST/RestHelper.cs Outdated
Comment thread src/Commands/Utilities/REST/RestHelper.cs
Comment thread src/Commands/Utilities/REST/RestHelper.cs Outdated
…tively

Co-authored-by: Copilot <copilot@github.com>
Copy link
Copy Markdown
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 6 out of 6 changed files in this pull request and generated 3 comments.

Comment thread src/Commands/Utilities/REST/RestHelper.cs
Comment thread src/Commands/Utilities/REST/RestHelper.cs Outdated
Comment thread src/Commands/ManagementApi/GetUnifiedAuditLog.cs Outdated
… improved clarity and consistency

Co-authored-by: Copilot <copilot@github.com>
@gautamdsheth gautamdsheth merged commit 96fecab into dev Apr 22, 2026
3 checks passed
@gautamdsheth gautamdsheth deleted the feat/improve-concurrency branch April 22, 2026 18:32
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.

2 participants