Skip to content

Simplify the GrpcHandler and add tests #5356

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 5, 2025
Merged

Simplify the GrpcHandler and add tests #5356

merged 2 commits into from
Aug 5, 2025

Conversation

sjf
Copy link
Contributor

@sjf sjf commented Aug 4, 2025

Simplify the GrpcHandler and add tests before adding support for JSON encoding for external clients.

  • Just have two functions handleUnaryRequest and handleStreamingRequest, instead of creating a GrpcHandler object for every request and then calling class methods on it.
  • Remove redundant try/catch and empty finally blocks. Each of the two handler functions has it's own try/catch.
  • Each of the two functions is responsible for posting the result to the webview- Instead of unary and streaming responses being handled at different levels.
  • Use the GrpcRequest and GrpcCancel types.
  • Add comprehensive integration tests.

Important

Simplify GrpcHandler by replacing it with functions and add comprehensive tests for request handling.

  • Refactoring:
    • Replace GrpcHandler class with handleUnaryRequest and handleStreamingRequest functions in grpc-handler.ts.
    • Remove redundant try/catch and empty finally blocks.
    • Use GrpcRequest and GrpcCancel types for request handling.
  • Behavior:
    • handleUnaryRequest and handleStreamingRequest post results directly to the webview.
    • Unified error handling within each function.
  • Testing:
    • Add comprehensive tests in grpc-handler.test.ts for unary and streaming requests, error scenarios, and request cancellation.
    • Test concurrent request handling and ensure correct response posting.

This description was created by Ellipsis for 515eec3. You can customize this summary. It will automatically update as commits are pushed.

* Use two functions handleUnaryRequest and handleStreamingRequest, instead of creating a GrpcHandler object and calling class methods on it.
* Remove redundant try/catch and empty finally blocks. Each of the two handler functions has it's own try/catch.
* Each of the two functions is responsible for posting the result to the webview- Instead of unary and streaming responses being handled at different levels.
* Use the GrpcRequest and GrpcCancel types.
Copy link

changeset-bot bot commented Aug 4, 2025

⚠️ No Changeset found

Latest commit: 515eec3

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@sjf sjf changed the title Simplify the GrpcHandler Simplify the GrpcHandler and add tests Aug 4, 2025
Copy link
Contributor

github-actions bot commented Aug 4, 2025

Coverage Report

Extension Coverage

Base branch: 47%

PR branch: 48%

✅ Coverage increased or remained the same

Webview Coverage

Base branch: 17%

PR branch: 17%

✅ Coverage increased or remained the same

Overall Assessment

Test coverage has been maintained or improved

Last updated: 2025-08-04T23:03:18.516717

@sjf sjf merged commit 7eeb43a into main Aug 5, 2025
13 checks passed
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