Post

How our "perfect" one-line isOwner() function in Next.js started always returning true. Spoiler: It is because of server functions... Wrote about the bug, the fix, and the "magic" that caused it: marma.dev/articles/202... #webdev #javascript #typescript #react #nextjs #serverfunctions

marma.devmarma.dev

1 repost19 likes

i imagine javascript haters will say this is a problem with js because of truthiness, not next.js, but i don't think that's right it seems insane to me that next.js would secretly turn this into an async func returning a promise, ever at the bare minimum it should have automatically awaited it???

We are using TypeScript. We could also explicitly set the return type, but the problem is that the types don't exist during runtime. They are being checked through the LSP during development and before building. Our function was being changed to an async one after type checking.