elysiajs / elysia

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

[Sucrose] unexpected isContextPassToFunction error #721

Open cybercoder-naj opened 1 month ago

cybercoder-naj commented 1 month ago

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

SaltyAom commented 1 month ago

Should have been fixed in c1ad341, published under 1.1.2

crishoj commented 1 month ago

Confirmed fixed in 1.1.2.

With 1.1.1:

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

@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
0-don commented 1 month ago

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
0-don commented 1 month ago

the issue still exist in 1.1.4

eekelof commented 4 weeks ago

1.1.5 fixed it for me

ItPohgero commented 3 weeks ago

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.