elysiajs / elysia

Ergonomic Framework for Humans
https://elysiajs.com
MIT License
10.59k stars 226 forks source link

return error no longer works in derive() on 1.1.18 #865

Closed sunnylqm closed 1 month ago

sunnylqm commented 1 month ago

What version of Elysia is running?

1.1.18

What platform is your computer?

Darwin 24.0.0 arm64 arm

What steps can reproduce the bug?

export const checkLogined = new Elysia().derive(
  { as: 'scoped' },
  ({ headers, error }) => {
    const token = headers['x-accesstoken'];
    const session = token && checkTokenWithInfo(token, 'user');
    if (!session) {
      return error(401, {
        message: 'Unauthorized',
      });
    }
    return {
      userId: session.uid,
    };
  },
);

What is the expected behavior?

it worked fine before 1.1.18

What do you see instead?

QQ_1728179750160

Additional information

No response

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

yes

SaltyAom commented 1 month ago

fix with 93d457b