Plugin working locally But not in live

Continuing the discussion from Timeline - Social Network like News Feed UI in Topic List:

My above plugin working perfectly on localhost as it in screenshots. But I can’t see any updates in live website.

Looks like below code is not working. I am not getting unread_post field in latest.json response.

https://github.com/VinkasHQ/discourse-timeline/blob/master/plugin.rb#L11-L23

I can see the plugin name in both plugins list and upgrade pages.

I just fixed it myself :slight_smile:

2 Likes

What was wrong? :bug:

1 Like

@sam TopicListItemSerializer is inherited class of ListableTopicSerializer. If I monkey patch ListableTopicSerializer it is not working on live version. Instead if I monkey patch TopicListItemSerializer it is working on both local and live. Weird :flushed:

3 Likes

wow, strange, maybe the serializer was being patched too late in the process after it already cached certain data.

Yes. I think so. May be eager_load or cache_classes doing that part.

I just spent a long time debugging an issue caused by this. I was doing

add_to_serializer(:admin_user, :somefield)...

which worked fine in development, but not in production. Changing it to :admin_detailed_user fixed the problem (admin_detailed_user inherits from admin_user).

It would be good if we can either fix this, or at least add a warning. Differences between dev/prod are painful!

5 Likes

100% in agreement here :heart: if you can figure out any way to make this explode consistently on both prod and dev it would be awesome… My guess is that this is somehow related to the reloaders.

One sad thing about relying on “reload” magic is that there is a lot of magic. Its one big reason we moved away from using sprockets (and never jumped on the spring train) … it just got too hard to fit the mold of reloading without side effects.

(this could be not reload related, but hey, its a nice story :crazy_face: )

6 Likes

I just ran into this issue again and came across this topic. Looks like @sam added a fix to the plugin API which resolves this issue :smiley:

https://github.com/discourse/discourse/commit/bd5fa1737d42a958bb5cda35ae5bab2464d4e084

So, to close this out: if you run into this issue, make sure you use add_to_serializer API rather than modifying the class yourself.

5 Likes