amnaredo / test

0 stars 0 forks source link

Deserialization fails when keys with default value are missing on JS, works on JVM #135

Open amnaredo opened 3 years ago

amnaredo commented 3 years ago

My unit tests are failing on the javascript side when attempting to deserialize a sealed case class. This doesn't happen on the JVM. The exception I am getting (pulled from Chrome):

$c_Lupickle_Invalid$Data {s$1: null, e$1: null, stackTrace$1: null, data$3: $c_Lupickle_Js$Obj, msg$3: "Key Missing: caller"…}data$3: $c_Lupickle_Js$Obje$1: nullmsg$3: "Key Missing: caller"s$1: [..]

If i change all variables with defaults to something else it works fine.

I am using ScalaJs 0.6.4 and uPickle 0.3.4

ID: 100 Original Author: tannerezell

amnaredo commented 3 years ago

Can you provide a complete, standalone repro?

Original Author: lihaoyi

amnaredo commented 3 years ago

I've actually been trying to do that for the last couple hours with no success. I seem to get completely random results from uPickle at times. One compile it works fine, another it doesn't. Sometimes cleaning it makes it happy, sometimes it has no effect. Sometimes making a simple change to a class changes the outcome, even reverting that change can keep uPickle happy.

It's the strangest thing, sometimes uPickle will serialize with defaults, sometimes it doesn't. I honestly can't determine the source of the behavior.

I restructured my project into a multi project in sbt and so far knock on wood it'll keep being happy.

I'm sorry I couldn't be more helpful. this one has me puzzled

Original Author: tannerezell

amnaredo commented 3 years ago

I'm closing this. I can't duplicate it and falling back to manual readers/writers isn't too awful and provides a good deal of stability for what im doing.

I have to wonder, is there an easy way when writing a Writer[T] to bring in the "$type" field?

Original Author: tannerezell

amnaredo commented 3 years ago

This is still an issue with uPickle 0.4.3. Unfortunately it is very difficult to reproduce and appears to be a build-time issue (happens consistently for a given build, but builds with seemingly unrelated differences result in this behavior appearing and disappearing).

If I can get a useful repro together (something that repros >25% of the time) should this be re-opened or should I submit a new issue?

Original Author: maanaben

amnaredo commented 3 years ago

@maanaben let's put it in a new issue

Original Author: lihaoyi