Skip to content

InvalidCookieSignature errors are not caught by onError #964

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

Closed
dtinth opened this issue Dec 23, 2024 · 3 comments
Closed

InvalidCookieSignature errors are not caught by onError #964

dtinth opened this issue Dec 23, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@dtinth
Copy link

dtinth commented Dec 23, 2024

What version of Elysia is running?

1.2.2

What platform is your computer?

Darwin 24.1.0 arm64 arm

What steps can reproduce the bug?

import Elysia, { t } from "elysia";

new Elysia()
  .onError(({ code }) => {
    console.log("[onError]", code);
    return { error: { code } };
  })
  .get(
    "/bug",
    async ({ cookie }) => {
      if (!cookie.bug.value) {
        cookie.bug.value = new Date().toISOString();
      }
      return { value: cookie.bug.value };
    },
    {
      cookie: t.Cookie(
        { bug: t.Optional(t.String()) },
        { secrets: crypto.randomUUID(), sign: ["bug"] }
      ),
    }
  )
  .get("/crash", async () => {
    throw new Error("something");
  })
  .listen(3000);
  1. Run the server
  2. Visit /bug
  3. Restart the server
  4. Visit /bug again

What is the expected behavior?

Response should be

{"error":{"code":"INVALID_COOKIE_SIGNATURE"}}

Also should log in console:

[onError] INVALID_COOKIE_SIGNATURE

What do you see instead?

Response does not follow the format defined in onError

"bug" has invalid cookie signature

Also no log.

Additional information

The onError is not called at all

Have you try removing the node_modules and bun.lockb and try again yet?

No response

@dtinth dtinth added the bug Something isn't working label Dec 23, 2024
@SaltyAom
Copy link
Member

SaltyAom commented Dec 27, 2024

Should have been fixed with e34c73c, going to be published under 1.2.7

@SaltyAom
Copy link
Member

Published under 1.2.7.

Feel free to reopen tag me or reopen the issue if the problem still happen.

@dtinth
Copy link
Author

dtinth commented Dec 27, 2024

thank you, confirmed fixed

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants