I am trying to invoke a Cloudflare Workflow via RPC from a different Worker. this workflow is create

I am trying to invoke a Cloudflare Workflow via RPC from a different Worker. this workflow is created as intended, but I want the invoker to receive the id so as to do stuff with the workflow. these are my methods:
export default {
  async fetch(): Promise<Response> {
    // Return 400 for direct HTTP requests since workflows should be triggered via bindings
    return Response.json(
      { error: "Workflows must be triggered via bindings" },
      { status: 400 },
    );
  },
  async create({ params }: { params: InitSyncParams }, env: Env) {
    const workflow = await env.SYNC_REPO_INIT_WORKFLOW.create({ params });
    return workflow.id;
  },
  async terminate(id: string, env: Env) {
    const instance = await env.SYNC_REPO_INIT_WORKFLOW.get(id);
    await instance.terminate();
  },
  async getInstanceStatus(id: string, env: Env) {
    const instance = await env.SYNC_REPO_INIT_WORKFLOW.get(id);
    return await instance.status();
  },
};


unfortunately, when I'm trying to get
.id
, I get the following error message:
Error: AssertionError: Could not retrieve instance metadata
.

would appreciate any help. prefer using the JavaScript RPC as that would mean I don't have to implement any auth layer or try to figure out how to programmtically link the URL of my Workers
Was this page helpful?