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

Invalid context on .onStart, onStop #969

Closed
nxht opened this issue Dec 24, 2024 · 1 comment
Closed

Invalid context on .onStart, onStop #969

nxht opened this issue Dec 24, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@nxht
Copy link

nxht commented Dec 24, 2024

What version of Elysia is running?

1.2.2

What platform is your computer?

Linux 5.15.167.4-microsoft-standard-WSL2 x86_64 x86_64

What steps can reproduce the bug?

import Elysia from 'elysia';

export const app = new Elysia()
  .decorate('foo', 'bar')
  .onStart(({ decorator: { foo } }) => {
    console.log(foo);
  })
  .listen(0);

What is the expected behavior?

Prints bar

What do you see instead?

Error:

TypeError: Right side of assignment cannot be destructured
      at /home/wsladmin/typescript/test-elysia-simple/src/index.ts:9:5
      at /home/wsladmin/typescript/test-elysia-simple/node_modules/elysia/src/adapter/bun/index.ts:97:24
      at listen (/home/wsladmin/typescript/test-elysia-simple/node_modules/elysia/src/index.ts:6029:31)
      at /home/wsladmin/typescript/test-elysia-simple/src/index.ts:11:4

When tested without destructuring, it shows that decorator in undefined

It seems that the context here should be looking at the Elysia instance but it's looking at adapter instance instead.

Additional information

Same issue causes context.server to be undefined.

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

Yes.

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

Fixed in e83daaf, published under 1.2.3

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