Skip to content

sucrose: context pass to function with sub context #1596

@Riant

Description

@Riant

What version of Elysia is running?

1.4.16

What platform is your computer?

Windows 10

What environment are you using

bun 1.2.19

Are you using dynamic mode?

NO

What steps can reproduce the bug?

return new Elysia().get('/test', (context) => {
    console.log('path >>> ', context.path)
    test2(context)
    return {id: 'test'}
  })
  function test2(context) {
    console.log('test2 >>> ', context.query)
  }

如上所示,此时访问 /test?id=1,test2 中的输出会是 undefined,但是当我们将console.log('path >>> ', context.path) 行注释掉之后,test2 中的输出就正常了。

What is the expected behavior?

函数 test2 中应该能够正常访问 context.query

What do you see instead?

函数test2 输出了 test2 >>> undefined

Additional information

即使我们将调用 test2 之后的 return 语句改为return {path: context.path}, test2 中也会取不到 context.query

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

NO

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingreviewWaiting for issue reporter approval

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions