Skip to content

feat: add $rejectPendingCalls #26

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
Jul 14, 2025

Conversation

AriPerkkio
Copy link
Contributor

@AriPerkkio AriPerkkio commented Jul 13, 2025

Description

On Vitest we need to reject pending methods on Worker side. While rpc.$close does this perfectly, we cannot use it. We are using the rpc channel for transferring the rejected methods, so $close is closing the channel before rejection are sent to main thread.

This PR adds new method that can be used to explicitly reject the pending methods.

Linked Issues

Additional context

@AriPerkkio AriPerkkio force-pushed the feat/reject-pending-calls branch from 829115b to 6533e1c Compare July 13, 2025 16:11
@AriPerkkio AriPerkkio marked this pull request as ready for review July 13, 2025 16:11
@antfu antfu requested a review from sheremet-va July 14, 2025 08:14
src/index.ts Outdated
@@ -278,6 +291,16 @@ export function createBirpc<RemoteFunctions = Record<string, never>, LocalFuncti
off(onMessage)
}

function rejectPendingCalls(handler: PendingCallHandler) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

The naming seems confusing because you are not required to reject it, it just calls a function on every entry

@sheremet-va sheremet-va merged commit 5cc1df9 into antfu:main Jul 14, 2025
2 checks passed
@AriPerkkio AriPerkkio deleted the feat/reject-pending-calls branch July 14, 2025 16:53
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.

3 participants