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

Returning a Response from the durable with an error status code throws an exception #45

Open
roygonen opened this issue Dec 26, 2023 · 0 comments

Comments

@roygonen
Copy link

I'm returning from my durable object's function a response:

handleRequest:

    ...
     return new Response("Missing auth header", { status: 401 });
    ...

worker.js:

router
  .all("*", withDurables())
  .get("/counter/:counterId", async (request, env) => {
    const counter = Counter.get(id);
    return counter.handleRequest(request);
  });

export default {
  fetch: async (request, env, ctx) =>
    router
      .handle(request, env, ctx)
      .then(json)
      .catch(error)
};

I expect it the return as a message, but instead it throws an error:
TypeError: Body has already been used. It can only be used once. Use tee() first if you need to read it twice.

seems like in proxy-durable.js/catchErrors the body is being used already, therefore i'm getting a 500 response

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

No branches or pull requests

1 participant