elysiajs / elysia

Ergonomic Framework for Humans

Home Page:https://elysiajs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Sucrose] unexpected isContextPassToFunction error

cybercoder-naj opened this issue · comments

What version of Elysia.JS is running?

1.1.1

What platform is your computer?

Linux 6.6.32-1-lts x86_64 unknown

What steps can reproduce the bug?

  1. Clone this repository
  2. Change the branch to fix/onresponse-missing-function
  3. Change directory to preview, cd preview/
  4. Run the code, bun run src/index.ts

What is the expected behavior?

No warning message.

What do you see instead?

[Sucrose] unexpected isContextPassToFunction error, please report the following to the developer:
---
O)=
---

Additional information

No response

Should have been fixed in c1ad341, published under 1.1.2

Confirmed fixed in 1.1.2.

With 1.1.1:

[Sucrose] unexpected isContextPassToFunction error, please report the following to the developer:
---
Y)=
---
commented

@SaltyAom getting this under 1.1.3, using a mounted instance of Elysia:

[Sucrose] warning: unexpected isContextPassToFunction error, you may continue development as usual but please report the following to the developer:
--- body ---
{{request:J,path:j})=>X(new Request(a0(J.url,j.slice(Z)||"/"),J))
--- context ---
newRequest(a0(J.url, j.slice(Z)||"/"), J
commented

yes having same issue aswell on nextjs build

Collecting page data  ..[Sucrose] warning: unexpected isContextPassToFunction error, you may continue development as usual but please report the following to the developer
commented

the issue still exist in 1.1.4

1.1.5 fixed it for me

Just in production
i solv with this pattern

If you're encountering this error in Sucrose, it often happens when you're not destructuring ctx properly in an async function.

.get("xxx", async (ctx): Promise => {
ctx.cookie; // This can cause the error
});
Can be fixed by correctly destructuring the cookie from ctx:

.get("xxx", async ({ cookie }): Promise => {
// Now you can use the cookie without issues
});

This change prevents the isContextPassToFunction error.