Skip to content

feat(server): enhance call util to support signal and lastEventId options#687

Merged
dinwwwh merged 1 commit into
mainfrom
feat/server/support-signal-and-lastEventId-for-call-util
Jun 25, 2025
Merged

feat(server): enhance call util to support signal and lastEventId options#687
dinwwwh merged 1 commit into
mainfrom
feat/server/support-signal-and-lastEventId-for-call-util

Conversation

@dinwwwh
Copy link
Copy Markdown
Member

@dinwwwh dinwwwh commented Jun 25, 2025

Summary by CodeRabbit

  • New Features

    • Enhanced support for additional optional parameters when invoking procedures, including cancellation signals and event identifiers.
  • Bug Fixes

    • Improved validation to ensure only correct types are accepted for new optional parameters.
  • Tests

    • Expanded and updated test coverage to verify correct handling and validation of new optional parameters.

@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 25, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
orpc ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 25, 2025 9:07am

@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Jun 25, 2025
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 25, 2025

Walkthrough

The call function in procedure-utils.ts was updated to support additional options, specifically signal and lastEventId, alongside context. The test files were updated to reflect and validate this extended options support, including type checks and runtime assertions for the new parameters.

Changes

File(s) Change Summary
packages/server/src/procedure-utils.ts Updated call function signature to accept signal and lastEventId in options; refactored option handling and invocation logic.
packages/server/src/procedure-utils.test.ts Modified tests to include signal and lastEventId in options; updated assertions to match new invocation signature.
packages/server/src/procedure-utils.test-d.ts Expanded type tests to cover signal and lastEventId support; added negative tests for invalid types.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant ProcedureUtils
    participant ProcedureClient

    Caller->>ProcedureUtils: call(procedure, input, {context, signal, lastEventId})
    ProcedureUtils->>ProcedureClient: createProcedureClient(procedure, options)
    ProcedureClient->>ProcedureUtils: returns clientFn
    ProcedureUtils->>ProcedureClient: clientFn(input, options)
    ProcedureClient-->>ProcedureUtils: result
    ProcedureUtils-->>Caller: result
Loading

Poem

In the warren of code, new options appear,
With signals and IDs, the path is now clear.
Tests hop along, both type-safe and bright,
Ensuring each call is handled just right.
🐇✨
More choices for rabbits, more reasons to cheer!

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @unnoq, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the call utility function within the server package to support signal and lastEventId options. This provides greater control over client-side request behavior, such as cancellation and event stream management, by passing these options down to the underlying client. The changes include updates to the core implementation, unit tests, and type definitions to ensure robustness and type safety.

Highlights

  • Enhanced 'call' utility: The call utility function now accepts signal (for request cancellation via AbortSignal) and lastEventId options, aligning its capabilities with common client-side request patterns, particularly useful for streaming or long-polling scenarios.
  • Type Safety: Updated TypeScript definitions and added new type tests (.test-d.ts) to ensure correct usage and strict type-checking for the new signal and lastEventId options, preventing invalid types from being passed.
  • Option Propagation: The newly supported signal and lastEventId options are now correctly propagated from the call utility through createProcedureClient to the underlying client function, ensuring they are utilized in the actual request execution.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 25, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jun 25, 2025

More templates

@orpc/arktype

npm i https://pkg.pr.new/@orpc/arktype@687

@orpc/client

npm i https://pkg.pr.new/@orpc/client@687

@orpc/contract

npm i https://pkg.pr.new/@orpc/contract@687

@orpc/experimental-durable-event-iterator

npm i https://pkg.pr.new/@orpc/experimental-durable-event-iterator@687

@orpc/hey-api

npm i https://pkg.pr.new/@orpc/hey-api@687

@orpc/nest

npm i https://pkg.pr.new/@orpc/nest@687

@orpc/openapi

npm i https://pkg.pr.new/@orpc/openapi@687

@orpc/openapi-client

npm i https://pkg.pr.new/@orpc/openapi-client@687

@orpc/react

npm i https://pkg.pr.new/@orpc/react@687

@orpc/react-query

npm i https://pkg.pr.new/@orpc/react-query@687

@orpc/server

npm i https://pkg.pr.new/@orpc/server@687

@orpc/shared

npm i https://pkg.pr.new/@orpc/shared@687

@orpc/solid-query

npm i https://pkg.pr.new/@orpc/solid-query@687

@orpc/standard-server

npm i https://pkg.pr.new/@orpc/standard-server@687

@orpc/standard-server-aws-lambda

npm i https://pkg.pr.new/@orpc/standard-server-aws-lambda@687

@orpc/standard-server-fetch

npm i https://pkg.pr.new/@orpc/standard-server-fetch@687

@orpc/standard-server-node

npm i https://pkg.pr.new/@orpc/standard-server-node@687

@orpc/standard-server-peer

npm i https://pkg.pr.new/@orpc/standard-server-peer@687

@orpc/svelte-query

npm i https://pkg.pr.new/@orpc/svelte-query@687

@orpc/tanstack-query

npm i https://pkg.pr.new/@orpc/tanstack-query@687

@orpc/valibot

npm i https://pkg.pr.new/@orpc/valibot@687

@orpc/vue-colada

npm i https://pkg.pr.new/@orpc/vue-colada@687

@orpc/vue-query

npm i https://pkg.pr.new/@orpc/vue-query@687

@orpc/zod

npm i https://pkg.pr.new/@orpc/zod@687

commit: e6c74c9

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request introduces support for signal and lastEventId options to the call utility. The changes include updates to type definitions and runtime tests. A potential improvement involves explicitly including signal and lastEventId in the Omit type within procedure-utils.ts to ensure these options are correctly passed through.

Comment thread packages/server/src/procedure-utils.ts
Comment on lines +71 to +72
const options = resolveMaybeOptionalOptions(rest)
return createProcedureClient(procedure, options)(input, options)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Consider destructuring the options to explicitly pass signal and lastEventId to the client call, improving readability.

  const options = resolveMaybeOptionalOptions(rest)
  const { signal, lastEventId } = options;
  return createProcedureClient(procedure, options)(input, { signal, lastEventId })

Comment thread packages/server/src/procedure-utils.test.ts
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/server/src/procedure-utils.ts (1)

42-51: Consider updating documentation.

The JSDoc comment could be enhanced to mention the new signal and lastEventId options for better developer experience.

 /**
  * Directly call a procedure without creating a client.
  *
  * @example
  * ```ts
  * const output = await call(getting, 'input')
  * const output = await call(getting, 'input', { context: { db: 'postgres' } })
+ * const output = await call(getting, 'input', { 
+ *   context: { db: 'postgres' }, 
+ *   signal: AbortSignal.timeout(5000),
+ *   lastEventId: 'event-123'
+ * })
  * ```
  *
  */
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between add5acf and e6c74c9.

📒 Files selected for processing (3)
  • packages/server/src/procedure-utils.test-d.ts (2 hunks)
  • packages/server/src/procedure-utils.test.ts (1 hunks)
  • packages/server/src/procedure-utils.ts (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/server/src/procedure-utils.ts (3)
packages/client/src/types.ts (2)
  • ClientOptions (8-12)
  • ClientPromiseResult (24-24)
packages/shared/src/args.ts (1)
  • resolveMaybeOptionalOptions (5-7)
packages/server/src/procedure-client.ts (1)
  • createProcedureClient (71-123)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: publish-commit
  • GitHub Check: lint
🔇 Additional comments (9)
packages/server/src/procedure-utils.test.ts (2)

51-51: LGTM: Test properly covers the new options.

The test correctly includes the new signal and lastEventId options alongside the existing context option.


58-58: LGTM: Test expectation updated correctly.

The test now properly verifies that the client is called with the full options object, aligning with the implementation changes.

packages/server/src/procedure-utils.test-d.ts (3)

17-20: LGTM: Comprehensive type testing for new options.

The type tests properly validate that signal and lastEventId options are supported alongside the existing context option.


21-24: LGTM: Good coverage of optional context scenarios.

The tests correctly verify that calls without a context argument are allowed when all context fields are optional, which maintains backward compatibility.


34-37: LGTM: Proper negative type testing.

The @ts-expect-error comments correctly ensure that invalid types for signal and lastEventId are caught by TypeScript, maintaining type safety.

packages/server/src/procedure-utils.ts (4)

1-1: LGTM: Proper imports for new functionality.

The additional imports for ClientOptions and ClientPromiseResult are necessary for the enhanced type signature.


7-7: LGTM: Import follows established pattern.

The import of resolveMaybeOptionalOptions is consistent with how optional options are handled throughout the codebase.


68-68: LGTM: Well-designed type extension.

The use of Omit<ClientOptions<Record<never, never>>, 'context'> correctly allows signal and lastEventId options while avoiding duplication of the context field that's already handled by CreateProcedureClientOptions.


71-72: LGTM: Proper options normalization and usage.

The implementation correctly:

  • Uses resolveMaybeOptionalOptions to normalize the rest parameters
  • Passes the normalized options to both createProcedureClient and the client invocation
  • Follows the established pattern for handling optional options in the codebase

@dinwwwh dinwwwh merged commit 57b0b5d into main Jun 25, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant