Skip to content
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

Repro of issue with RPC & promise pipelining #3706

Closed
wants to merge 1 commit into from
Closed

Conversation

penalosa
Copy link
Contributor

@penalosa penalosa commented Mar 12, 2025

Reproduces what we think is a bug in the runtime, that is related to promise pipelining.

The sample sets up three Workers that service bind in the following way: worker-a -> proxy-worker -> user-worker. The proxy Worker acts as a "proxy", by forwarding the foo() RPC calls to the user-worker

foo(emoji) {
    return this.env.USER.foo(emoji);
}

Running this sample will result in worker-a throwing an error: RPC stub used after being disposed..

@mhart
Copy link
Contributor

mhart commented Mar 13, 2025

Just to clarify – the promise pipelining works without the intermediate proxy-worker right? It's the introduction of the proxy that's (presumably) making workerd think the stub is done and disposing of it too early.

import { WorkerEntrypoint } from 'cloudflare:workers';
export default class Worker extends WorkerEntrypoint {
fetch() {}
foo(emoji) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the error still happen if this is declared async or if the result below is wrapped in a Promise? I expect it would, but just checking

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah—this reproduces with an async function (with and without await)

@CarmenPopoviciu
Copy link
Contributor

Just to clarify – the promise pipelining works without the intermediate proxy-worker right? It's the introduction of the proxy that's (presumably) making workerd think the stub is done and disposing of it too early.

yes that is correct. without that "middle layer" proxy Worker, everything works fine. Once we add that proxy Worker, things break

@CarmenPopoviciu
Copy link
Contributor

@mhart also to clarify, I have also tested this setup in production, by deploying three workers with this config, and am seeing the same error

@CarmenPopoviciu
Copy link
Contributor

one more detail here is that the following works as expected, though it kind of defeats the purpose of promise pipelining

export default {
  async fetch(request, env) {
    const foo = await env.PROXY.foo('🐜');
    return new Response(await foo.bar.buzz());
  },
};

@danlapid danlapid closed this Mar 19, 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.

4 participants