Closed OmniThinker closed 1 year ago
@Pederaugust Hi there! Thanks for the kind words :-)
So the key info in that stack trace is here:
taoensso.nippy/throw-unfreezable nippy.clj: 1020
clojure.lang.ExceptionInfo: Unfreezable type: class next.jdbc.result_set$navize_row$fn__17909
as-str: "#object[next.jdbc.result_set$navize_row$fn__17909 0x621cc708 \"next.jdbc.result_set$navize_row$fn__17909@621cc708\"]"
type: next.jdbc.result_set$navize_row$fn__17909
Basically the problem is that you're trying to put something into your Ring session (a next.jdbc type) that Carmine doesn't know how to write to Redis (doesn't know how to serialize with Nippy).
I'm not familiar with the particular type here, but I suspect that it should be possible to coerce it to a standard Clojure data type before adding it to your session.
Does that make sense?
Edit to add: when you're using Ring's standard in-memory store, it can safely hold any kind of type since its values are all just JVM objects in memory. But when you switch to a persistent store like Carmine's store, you need to be mindful of the types being stored in sessions since there must be some way to serialize those types to/from Redis.
Carmine uses Nippy for its serialization, so can handle many different types - including every standard Clojure type. But Nippy will usually be unfamiliar with library-specific types (like your jdbc.next type here).
Wow, thanks for the quick answer!
I think it makes sense. {:id 1, :email
edit:
(do
(println (-> (dissoc user :password_hash)
(dissoc :email_verification_token)
type))
(assoc (redirect "/account")
:session
(assoc session
:identity
(-> (dissoc user :password_hash)
(dissoc :email_verification_token))))
Gives me:
clojure.lang.PersistentArrayMap
So maybe I need to read up on the nippy docs?
Oh, so what I did was instead of dissocing, I just created an object with explicit keys and values. This solved the issue. So assume this was just a problem with the result received from next. Thanks for the guidelines! Keep up the good work!
I think it makes sense. {:id 1, :email , :username , :email_verified true} this is what I am trying to assoc to the session.
That shouldn't be a problem at all, Nippy happily supports clojure.lang.PersistentArrayMap
s.
So maybe I need to read up on the nippy docs?
That shouldn't be necessary, that Carmine uses Nippy is mostly an implementation detail unless you're specifically wanting to do something advanced to take further advantage of specific Nippy capabilities.
In your case, it looks like some JDBC result is sneaking into your session somewhere. You'll need to find where that's happening.
A few places I'd start:
user
in your code snippet aboveHope that helps!
Ah, great- so if removing the dissoc
helped, then it's likely the issue (1.) I mentioned above - I suspect that user
is some kind of jdbc.next type.
Even if Carmine is now satisfied, I'd suggest looking into the user
type since it's conceivable that it could cause issues elsewhere.
This advice depends on specifics, but it's often a good idea to ensure that you're not leaking DB-specific types into your application logic.
Best of luck!
Hey, love your contributions to open source. I have setup my ring-server to use the carmine-store. Context: I am running redis in docker. For development I use this configuration:
{:spec {:uri "redis://0.0.0.0:6379/0"}}
I am getting this error:
I am not sure why next gives an error when I use the carmine store? When I use the default store everything works fine.