Canned responses randomly not working (Discourse 2.2)

Didn’t investigate as I don’t have the know how. But I do know that ever since I’ve installed 2.2.1 when I click on a canned response nothing happens. This happens randomly, I can’t replicate it at will. Sometimes they work, sometimes they don’t. I have to reload the whole site for it to work.

This is what shows up in the console:

TypeError: i.get(“topic.posters”)[0].user.get is not a function. (In ‘i.get(“topic.posters”)[0].user.get(“username”)’, ‘i.get(“topic.posters”)[0].user.get’ is undefined)

Uncaught TypeError: i.get(...)[0].user.get is not a function
    at e.default (plugin-7414be04de5897403a5c16f2d50f60ddba9e5725993124e89d0a9ae3f0942a92.js:1)
    at n.apply (plugin-7414be04de5897403a5c16f2d50f60ddba9e5725993124e89d0a9ae3f0942a92.js:1)
    at n.send (ember_jquery-cf9339810550f9c92505dfbb37362c58a4a8a83bcee2d99174547b01c06ed7d3.js:16)
    at n [as send] (ember_jquery-cf9339810550f9c92505dfbb37362c58a4a8a83bcee2d99174547b01c06ed7d3.js:15)
    at n.triggerAction (ember_jquery-cf9339810550f9c92505dfbb37362c58a4a8a83bcee2d99174547b01c06ed7d3.js:15)
    at n.s [as sendAction] (ember_jquery-cf9339810550f9c92505dfbb37362c58a4a8a83bcee2d99174547b01c06ed7d3.js:16)
    at n.click (application-6157201f89cbc41715dde34af85ed4c9d799cece2e11aac8f0710af120c2affd.js:27)
    at n.trigger (ember_jquery-cf9339810550f9c92505dfbb37362c58a4a8a83bcee2d99174547b01c06ed7d3.js:16)
    at n [as trigger] (ember_jquery-cf9339810550f9c92505dfbb37362c58a4a8a83bcee2d99174547b01c06ed7d3.js:15)
    at e._run (ember_jquery-cf9339810550f9c92505dfbb37362c58a4a8a83bcee2d99174547b01c06ed7d3.js:9)

No clue what that means :smiley: Any guidance would be appreciated.

Are you still on 2.2.1, or have you now upgraded to 2.3?

Still? I just upgraded to 2.2.1 :smiley: Can’t keep up with the updates. Have a few custom plugins so I don’t hop onto the newest versions right away.

Er they’ve been working for me…

Yeah maybe it’s something on my end, I thought I’d share my problem to see if there is anyone else.

If you’re on tests-passed the first step is usually to get upgraded in case it was already reported and fixed.

I’m assuming you used the search already, 2.2 beta 1 is months old at this point, the chances of someone only noticing this issue now is quite slim.

1 Like

Correction: @WorldIsMine is on 2.2.1 not 2.2 beta1. I somehow missed that and he missed my mention of tests-passed.

2 Likes

Thank you for reopening. I will try to find a way to replicate it but it’s so random it’s not even funny. It can go hours without a problem, then for 30 min nothing but problems. And it’s been like that since the upgrade.

When the update was performed, no other plugins were updated, they were already at their latest version.
Only procourse-static-pages was added but I doubt this has to do with anything.

Extra info: this only happens on PM’s.

This happened prior to installing that plugin so it shouldn’t be that.
As far as the PM claim, not 100% sure on that. It’s just that I use canned responses for mainly PM’s, but so far didn’t get a problem using them in topics, only PM’s. So for now we can assume it’s PM only but can’t totally rule out topics just yet.

We did the upgrade to 2.2.1 and the installation of the procourse-static-pages at the same time.

1 Like

Still haven’t been able to replicate it. But, today I had another bug I’ve had since I’ve started using discourse. It’s rare, but it happens and it may be related. When I open up the composer and click the canned replies icon nothing happens, they just don’t open. The console gives me this: TypeError: undefined is not an object (evaluating ‘t.actions’)

This started happening a while ago.

@RGJ

I’ve tried safe mode like you’ve asked, turned off the custom theme + plugins. I only left the official plugins. The problem is still there and the console still throws:

Uncaught TypeError: i.get(…)[0].user.get is not a function
It points to this piece of code:

  exports.default = function (replyId, replyTitle, replyContent, model) {
    // Replace variables with values.
    if (model) {
      var vars = {
        user: model.get("user.username"),
        original_poster: model.get("topic.posters") ? model.get("topic.posters")[0].user.get("username") : "",
        reply_to: model.get("post.reply_to_user.username"),
        last_user: model.get("topic.last_poster_username"),
        reply_to_or_last: model.get("post.reply_to_user.username") || model.get("topic.last_poster_username")
      };

      for (var key in vars) {
        if (vars[key]) {
          replyTitle = replyTitle.replace("%{" + key + "}", vars[key]);
          replyContent = replyContent.replace("%{" + key + "}", vars[key]);
        }

Again, this only happens in PMs (so far).
My question is, is the safe-mode a reliable way to test? I mean, since I’ve disabled my custom plugins and theme and was able to encounter this error, then I am in the clear and something else is up, right?

EDIT: Like I’ve said before, can’t replicate this at will. But it happens in PM’s where there are usually more than two people invited.

EDIT2: I am on 2.2.1 so not sure why someone changed the topic to “previous version”.

EDIT3: Nevermind.

2.2.2 is not yet there but you are at latest stable now.

1 Like

It seems that topic.posters is not set on PM’s, but apparently sometimes it is set but does not resolve to a user?

If you get this error, can you open up your Developer toolbar (Firefox/Chrome: F12 then Console and look for the >> prompt) and enter

c = Discourse.__container__.lookup("controller:composer")
c.topic.posters
c.topic.posters[0]

and copy/paste the output here?

1 Like

I got this:

{extras: "latest", description: "Original Poster, Most Recent Poster", user: {…}}

Screenshot:

1 Like

Can you do

c.topic.posters[0].user

as well (after the other ones), and click the arrow in front of it before making a screenshot?

OK. I recall hitting the arrow but it didn’t open. Let me try again.