-
Notifications
You must be signed in to change notification settings - Fork 138
Description
I stumbled on a weird bug related to how NextJS treats the return values of cached functions. This not a bug with neverthrow, per se, but I wanted to get it on your radar.
NextJS's cache feature does not support functions that return classes. However, when Ok (or Err) is returned from a cached function, NextJS doesn't throw an error because it's an iterator. Instead, it tries to iterate over the class in an attempt to serialize it. For the Ok class, this means that the cached function then returns an empty array (very confusing for someone not familiar with neverthrow).
If you had a "gotcha's" section (or were considering adding one), I might suggesting adding a note about this because of how popular NextJS is and how likely devs might be to try caching (or serializing, in general) a Result object.
Or maybe this isn't as common as it seems... I don't know. I'm relatively new to NextJS, and I just started trying out neverthrow this afternoon.