Skip to content

threepointone/override-do-rpc-method

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is a repro for a bug where overriding a method on a Durable Object inside its constructor prevents RPC calls to that method.

The setup: A Durable Object class that has a method that is overridden inside its constructor.

class MyDO extends DurableObject {
  constructor(state: DurableObjectState, env: Env) {
    super(state, env);

    const _something = this.something.bind(this);
    this.something = (message: string) => {
      console.log("overriding something");
      return _something(message);
    };
  }
  async something(message: string) {
    return `asked ${message}: hello world`;
  }
}

Nothing fancy, we see that ::something() is overridden inside its constructor.

Let's call it from a worker:

export default {
  async fetch(_request: Request, env: Env, _ctx: ExecutionContext) {
    const id = env.MyDO.idFromName("my-durable-object");
    const myDO = env.MyDO.get(id);
    const res = await myDO.something("anyone there?");
    return new Response(res);
  },
};

Without the override, we get the expected response: asked anyone there?: hello world.

However, with the override, the request doesn't reach the Durable Object, and we get this error:

The RPC receiver does not implement the method "something".

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors