Skip to content

Conversation

@stevenvo
Copy link
Contributor

Summary

Fixes build error introduced in #2709 where StreamCancelFn assignment has incorrect function signature.

Problem

Build fails with:

pkg/wshrpc/wshclient/wshclientutil.go:66:24: cannot use func(ctx context.Context) error 
as func() value in assignment

Root Cause

  • StreamCancelFn is defined as func() in wshrpctypes.go:376
  • But was assigned a function with signature func(ctx context.Context) error in wshclientutil.go:66

Fix

Match the expected signature by:

  1. Removing parameters and return value from the lambda
  2. Using context.Background() for the SendCancel call

Testing

Build now succeeds without type errors.

Related

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 25, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Two files were modified to update the signature of the StreamCancelFn field in the RpcOpts type. The field type in wshrpctypes.go was changed from func() to func(context.Context) error. The corresponding usage in wshclientutil.go was updated to call SendCancel with a background context and handle the error return value appropriately within the streaming request-response helper function.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: fixing a type mismatch in the StreamCancelFn function signature assignment.
Description check ✅ Passed The description clearly explains the problem, root cause, and solution, all directly related to the changeset and build error resolution.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 90011a7 and d8f3b32.

📒 Files selected for processing (2)
  • pkg/wshrpc/wshclient/wshclientutil.go
  • pkg/wshrpc/wshrpctypes.go
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: esimkowitz
Repo: wavetermdev/waveterm PR: 1790
File: pkg/remote/fileshare/wshfs/wshfs.go:122-122
Timestamp: 2025-01-22T01:28:41.417Z
Learning: The RpcClient in pkg/remote/fileshare/wshfs/wshfs.go is initialized and handled downstream by either main-server or wshcmd-connserver, as documented in the package comment.
📚 Learning: 2025-01-22T01:28:41.417Z
Learnt from: esimkowitz
Repo: wavetermdev/waveterm PR: 1790
File: pkg/remote/fileshare/wshfs/wshfs.go:122-122
Timestamp: 2025-01-22T01:28:41.417Z
Learning: The RpcClient in pkg/remote/fileshare/wshfs/wshfs.go is initialized and handled downstream by either main-server or wshcmd-connserver, as documented in the package comment.

Applied to files:

  • pkg/wshrpc/wshclient/wshclientutil.go
📚 Learning: 2025-01-22T22:27:25.739Z
Learnt from: esimkowitz
Repo: wavetermdev/waveterm PR: 1790
File: pkg/remote/connparse/connparse.go:76-82
Timestamp: 2025-01-22T22:27:25.739Z
Learning: The GetRpcContext() method in wshutil package is guaranteed to never return nil due to type constraints, making nil checks unnecessary.

Applied to files:

  • pkg/wshrpc/wshclient/wshclientutil.go
🪛 golangci-lint (2.5.0)
pkg/wshrpc/wshclient/wshclientutil.go

[error] 66-66: : # github.com/wavetermdev/waveterm/pkg/wshrpc/wshclient
pkg/wshrpc/wshclient/wshclientutil.go:66:24: cannot use func() {…} (value of type func()) as func(context.Context) error value in assignment

(typecheck)

🔇 Additional comments (1)
pkg/wshrpc/wshrpctypes.go (1)

376-376: Type definition change is correct, but creates a compilation failure with the usage site.

The change to func(context.Context) error follows Go conventions for context-aware cancellation. However, this creates a type mismatch with the assignment in wshclientutil.go line 66, where a func() lambda is being assigned to this field. This will cause a compilation failure (confirmed by the static analysis error in that file).

The issue needs to be fixed in wshclientutil.go by updating the lambda to match this signature.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +66 to +67
opts.StreamCancelFn = func() {
reqHandler.SendCancel(context.Background())

Choose a reason for hiding this comment

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

P1 Badge Stream cancel callback still mismatches web handler signature

The new zero-arg StreamCancelFn here still does not match how it is consumed: handleRemoteStreamFileFromCh in pkg/web/web.go expects a func(context.Context) error and passes that type through rpcOpts.StreamCancelFn, so after this change the web package will still fail to compile with a type error (func() vs func(context.Context) error). This patch therefore doesn’t resolve the build break that motivated it; building the web server will still halt at that call site.

Useful? React with 👍 / 👎.

StreamCancelFn was incorrectly defined as func() but is actually used as func(context.Context) error throughout the codebase.

This caused build failures in multiple places:

- wshclientutil.go:66: cannot use func(ctx context.Context) error as func() value

- web.go:255: cannot use func() as func(context.Context) error value

Fixed by correcting the type definition in wshrpctypes.go to match actual usage.

Fixes build errors introduced in wavetermdev#2709
@stevenvo stevenvo force-pushed the fix/rpc-stream-cancel-type-mismatch branch from d41b118 to d8f3b32 Compare December 25, 2025 16:51
@stevenvo
Copy link
Contributor Author

Closing to create new PR with accurate description. Initial analysis was incorrect - the fix is simpler than described.

@stevenvo stevenvo closed this Dec 25, 2025
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.

1 participant