Infinite loading on quote


  • BINNED

    http://what.thedailywtf.com/t/the-evil-ideas-thread/1353/6?u=onyx

    Trying to quote this post (by using the quote button in editor after hitting reply to it) gets
    stuck in infinite loop.

    Firefox 30.0 on Linux

    I guess Discourse is sick of politics as well.


  • ♿ (Parody)

    No repro here.


  • BINNED

    @boomzilla said:

    No repro here.

    Added browser. Just tried again, full refresh and all, still gets stuck for me.


  • ♿ (Parody)

    Ah, yes, same results here. Was originally using Chrome 35 on Linux. FF30 / Linux hangs.



  • @Onyx said:

    http://what.thedailywtf.com/t/the-evil-ideas-thread/1353/6?u=onyx

    Trying to quote this post (by using the quote button in editor after hitting reply to it) gets
    stuck in infinite loop.

    Firefox 30.0 on Linux

    I guess Discourse is sick of politics as well.

    For what it's worth, it works fine in Firefox 28.0 on Windows. Of course, the quote box in the resulting post appears to be hilariously broken...

    [edit] Nevermind, it also happens in Firefox 28.0 - I apparently misinterpreted "this post" as being "this post that I just posted" as opposed to "this post that I just quoted".



  • Also affects Firefox 29 and Firefox 30 on Windows.

    Probably safe to assume it affects Firefox as a whole.


  • Discourse touched me in a no-no place

    @ChaosTheEternal said:

    Probably safe to assume it affects Firefox as a whole.

    Repro on FF32.0a under Linux...



  • So we're really just confirming that Firefox has a general distaste for politics at this point.


  • :belt_onion:

    Firefox is for serious things, like grumpy cat, not politics.



  • @Onyx said:

    I guess Discourse is sick of politics as well.

    I don't think it's politics - I have encountered that on more than one occasion but ascribed it to the general Discourse bugginess.


  • 🚽 Regular

    There's a POST being made to http://what.thedailywtf.com/logs/report_js_error:

    message=r+is+undefined&url=&line=&column=&window_location=http://what.thedailywtf.com/t/the-evil-ideas-thread/1353/5&stacktrace=Discourse.Quote.build@http://what.thedailywtf.com/assets/application-a7b62d3aca64a30f98626ebf02b489c2.js:7 Discourse.Composer<.importQuote/<@http://what.thedailywtf.com/assets/application-a7b62d3aca64a30f98626ebf02b489c2.js:1 m@http://what.thedailywtf.com/assets/vendor-0cf7f8ddcf2bd3b5854f3b875e88d515.js:6 d@http://what.thedailywtf.com/assets/vendor-0cf7f8ddcf2bd3b5854f3b875e88d515.js:6 w@http://what.thedailywtf.com/assets/vendor-0cf7f8ddcf2bd3b5854f3b875e88d515.js:6 @http://what.thedailywtf.com/assets/vendor-0cf7f8ddcf2bd3b5854f3b875e88d515.js:8 n.prototype.flush@http://what.thedailywtf.com/assets/vendor-0cf7f8ddcf2bd3b5854f3b875e88d515.js:6 r.prototype.end@http://what.thedailywtf.com/assets/vendor-0cf7f8ddcf2bd3b5854f3b875e88d515.js:6 r.prototype.run@http://what.thedailywtf.com/assets/vendor-0cf7f8ddcf2bd3b5854f3b875e88d515.js:6 w@http://what.thedailywtf.com/assets/vendor-0cf7f8ddcf2bd3b5854f3b875e88d515.js:6 v<@http://what.thedailywtf.com/assets/vendor-0cf7f8ddcf2bd3b5854f3b875e88d515.js:6 Discourse.Ajax<.ajax/n/s.success@http://what.thedailywtf.com/assets/application-a7b62d3aca64a30f98626ebf02b489c2.js:1 Z.Callbacks/c@http://what.thedailywtf.com/assets/vendor-0cf7f8ddcf2bd3b5854f3b875e88d515.js:3 Z.Callbacks/h.fireWith@http://what.thedailywtf.com/assets/vendor-0cf7f8ddcf2bd3b5854f3b875e88d515.js:3 n@http://what.thedailywtf.com/assets/vendor-0cf7f8ddcf2bd3b5854f3b875e88d515.js:4 .send/t/<@http://what.thedailywtf.com/assets/vendor-0cf7f8ddcf2bd3b5854f3b875e88d515.js:4

    And then it seems there's a syntax error interpreting the server response, which is a simple:

    OK

    Trying to debug the problem in vendor-bunch-of-hexnumbers.js is beyond what I can afford right now as, even after beautifying the code, it is too minimized (too many variables with the same name). Also, jslint is acting stupid again: "Stopping. (0% scanned)."

    PS: judging by the stack trace being posted, the relevant code should be around the following code somewhere, as it's the only place where I see an assigment to 'fireWith'. I don't understand those last two lines on the trace though.

    Z.Callbacks = function (e) {
            e = "string" == typeof e ? dt[e] || o(e) : Z.extend({}, e);
            var t, n, r, i, s, a, l = [],
                u = !e.once && [],
                c = function (o) {
                    for (t = e.memory && o, n = !0, a = i || 0, i = 0, s = l.length, r = !0; l && s > a; a++)
                        if (l[a].apply(o[0], o[1]) === !1 && e.stopOnFalse) {
                            t = !1;
                            break
                        }
                    r = !1, l && (u ? u.length && c(u.shift()) : t ? l = [] : h.disable())
                },
                h = {
                    add: function () {
                        if (l) {
                            var n = l.length;
                            ! function o(t) {
                                Z.each(t, function (t, n) {
                                    var r = Z.type(n);
                                    "function" === r ? e.unique && h.has(n) || l.push(n) : n && n.length && "string" !== r && o(n)
                                })
                            }(arguments), r ? s = l.length : t && (i = n, c(t))
                        }
                        return this
                    },
                    remove: function () {
                        return l && Z.each(arguments, function (e, t) {
                            for (var n;
                                (n = Z.inArray(t, l, n)) > -1;) l.splice(n, 1), r && (s >= n && s--, a >= n && a--)
                        }), this
                    },
                    has: function (e) {
                        return e ? Z.inArray(e, l) > -1 : !(!l || !l.length)
                    },
                    empty: function () {
                        return l = [], s = 0, this
                    },
                    disable: function () {
                        return l = u = t = void 0, this
                    },
                    disabled: function () {
                        return !l
                    },
                    lock: function () {
                        return u = void 0, t || h.disable(), this
                    },
                    locked: function () {
                        return !u
                    },
                    fireWith: function (e, t) {
                        return !l || n && !u || (t = t || [], t = [e, t.slice ? t.slice() : t], r ? u.push(t) : c(t)), this
                    },
                    fire: function () {
                        return h.fireWith(this, arguments), this
                    },
                    fired: function () {
                        return !!n
                    }
                };
            return h
        }```
    
    This is with FF 28 on Linux.

  • Banned

    God we need source maps desperately


  • ♿ (Parody)

    It's such a simple post. The only things that stuck out to me were the single quotes and the use of alt text for the image.


  • ♿ (Parody)

    @Zecc said:

    return !!n

    Doubleplusnegative.



  • @boomzilla said:

    >Zecc said:
    return !!n

    Doubleplusnegative.


    In doublebang notation.


  • 🚽 Regular

    In case you're genuinely unaware, that's the standard way of saying you want a boolean value out of n.

    Just like ! function o(t){...} (...) is a way of writing an Immediately-invoked function expression because it disambiguates1 from a function declaration followed by a parenthesized expression.

    1Spellchecker suggested "discombobulates" instead


  • ♿ (Parody)

    I don't really javascript (thank God), but I assumed it was some sort of type coercion of that sort. I stand by my mockery.


  • Discourse touched me in a no-no place

    Just about sums it up. Including the downsides:

    Harder to read and understand. It’s a horribly obscure way to do a type conversion. ! is NOT. So !true is false, and !false is true. !0 is true, and !1 is false.

    I was certainly aware of the idiom before today, and have used it (very) occasionally myself (mainly C), but it still grates on me when I see it.

    A Google search indicates it is a common idiom in Ruby as well. Which is where we came in...


  • BINNED

    @PJH said:

    I was certainly aware of the idiom before today, and have used it (very) occasionally myself (mainly C), but it still grates on me when I see it.

    Why would you do something like that in C? Since it's statically typed you can't coerce it without a cast anyway. Force it down to pure 1/0 integer? Does that even work in C?

    $ cat test.c 
    #include <stdio.h>
    
    int main(void)
    {
        int x = -3;
    
        printf("%d\n", !!(x));
    
        return;
    }
    $ gcc test.c -o test
    $ ./test 
    1
    $
    

    Well I'll be a son of an onion. It's still stupid, I agree.


  • ♿ (Parody)

    @PJH said:

    Ruby as well. Which is where we came in...

    Hang on, I thought that was javascript. Which, IIRC, is what most of the DC code actually is. I'm sure the posted code can't be Ruby, because it doesn't look totally silly to me.



  • @PJH said:

    A Google search indicates [!!] is a common idiom in Ruby as well. Which is where we came in...

    The !! idiom is a type cast - from a truthy (or falsey) value to a real boolean true or false.

    In a language where type inference is the norm (like javascript), using !! is a way to tell the compiler "this is a f***ing boolean value, no matter what you might think".

    Sometimes workarounds like that can be helpful to maintain some sanity.

    Especially in a language where

    var a = '1' + 1;
    var b = '1' - 1;
    

    results in a being "11" and b being 0.


  • BINNED

    @faoileag said:

    Especially in a language where

    var a = '1' + 1;
    var b = '1' - 1;

    results in a being "11" and b being 0.

    Don't even mention that. I love how JS uses + for both addition and concatenation. It's extremely fun when you have to apply special cases to it when, for example, you have a JSON from which a template is rendered, and it keeps insisting that page 21 comes after page 2.

    Should've made it infiniscroll...


    Filed under: For once, PHP did something right!


  • 🚽 Regular

    @boomzilla said:

    I'm sure the posted code can't be Ruby, because it doesn't look totally silly to me.

    I'm fairly certain the code in /assets/vendor-0cf7f8ddcf2bd3b5854f3b875e88d515.js is JavaScript.


  • Discourse touched me in a no-no place

    @Zecc said:

    I'm fairly certain the code in /assets/vendor-0cf7f8ddcf2bd3b5854f3b875e88d515.js is JavaScript.

    It started off with a lazy assumption on my part...


  • 🚽 Regular

    @Onyx said:

    int main(void)
    {
    // ...
        return;
    }
    How dare you?

    Filed under: -Wreturn-type


  • Discourse touched me in a no-no place

    @faoileag said:

    In a language where type inference is the norm (like javascript), using !! is a way to tell the compiler "this is a f***ing boolean value, no matter what you might think".

    The problem isn't type inference. The problem is that Javascript is a horrible POS with the semantics of the madhouse in places. Not that those places are important; they're only trivial little areas like equality, +, boolean logic, …


  • BINNED



  • The other fun thing I've seen with !! in JavaScript is the use of dealing with potentially null variables - think of an object being passed in to a function as a sort of dependency injection and instead of manually testing each property as being undefined, you can !! it and boom, instant bool.



  • var a = '1' - (-1)



  • @Matches said:

    var a = '1' - (-1)

    What the hell is wrong with you all? It's 2!

    var a = 2


    Filed under: You can't prove that I used a calculator...



  • My point was you can avoid ambiguous '+' performance by adding negative values.

    What could possibly go wrong?



  • Does this work?

    var a = --'1' + 1


  • Yeah, you read it as "BANG BANG it's a bool".



  • @Keith said:

    Does this work?

    var a = --'1' + 1</blockquote>
    


  • Ah, well we can get rid of that bracket at least:

    var a = '1' - -1
    

    Much clearer!

    Also, this seems to work:

    var a = - -'1' + 1
    

    Or, for optimum clarity:

    var a = - -'1' - -1


  • @Keith said:

    Ah, well we can get rid of that bracket at least:

    var a = '1' - -1
    

    Much clearer!

    Also, this seems to work:

    var a = - -'1' + 1
    

    Or, for optimum clarity:

    var a = - -'1' - -1</blockquote>
    
    var a = !'one';
    --a;
    a -= -a;
    a = -a;
    

  • ♿ (Parody)

    This sounds like shit that should be in the Bad or maybe Evil ideas thread.



  • var a = false
    --a = -1
    -1 -= -1... -2
    a = -a ...2 -2, no change? (I blame the eye doctor appt i just had. Eyes are fully dilated and this is really hard to read)

    I... think?



  • @ben_lubar said:

    var a = !'one';
    --a;
    a -= -a;
    a = -a;

    var a = '1'.length + 1
    

    Filed under: What? It passes the unit test!



  • printf("%d", '1' + 1);
    

    I get 50...


  • BINNED

    @Matches said:

    var a = '1' - (-1)

    That... would do it.

    I thank you for the idea, but come on, that's fucking idiotic that we have to do that shit. And then they ask me why I hate dynamic typing. Fucking JS. Even SQL does it better, sure it's a function instead of the operator, but at least it's unambiguous.

    Again, one place where I really have to say that, if we're having dynamic typing, PHP is Doing it Right™. It has proper coercion, type hinting in functions (FINALLY!), and two operators: + for addition, and . for concatenation.


  • BINNED

    @Keith said:

    var a = '1'.length + 1

    Evil ideas thread is that way



  • Don't look at me man, I avoid JS for pretty much everything. I make an exception for JSON serialization/transport - but I limit it to just newtonsoft object serialize/deserialize.

    [Edit: Disclaimer] I also don't normally do web work unless it's web services based. So YMMV



  • @Onyx said:

    I thank you for the idea, but come on, that's fucking idiotic that we have to do that shit.

    I think everyone was looking for really ugly ways of solving the problem. I suspect that you'd use parseInt() or something if you wanted it to be a bit clearer. Also, there's no need for the double negative:

    var a = '1' - 0 + 1

  • BINNED

    @boomzilla said:

    This sounds like shit that should be in the Bad or maybe Evil ideas thread.

    Implicit type conversion is definitely evil. I should add it to the thread if no one else has.


  • BINNED

    @Keith said:

    I suspect that you'd use parseInt() or something if you wanted it to be a bit clearer.

    I'd have to dig out the code, but I'm pretty sure the specific situation I mentioned required me to go out of my way to use parseInt(), while this kind of trick might be harmless. I'll take a look at it tomorrow, right now I'm enjoying my coffee done with any coding for the rest of the evening.



  • @Keith said:

    I think everyone was looking for really ugly ways of solving the problem. I suspect that you'd use parseInt() or something if you wanted it to be a bit clearer. Also, there's no need for the double negative:

    var a = '1' - 0 + 1</blockquote>
    
    var a = +'1' + 1;
    


  • I was just trolling.


  • Banned

    Confirmed, something about that post, and it's just an image, freaks Firefox out when you click reply, then use the "quote full post" button in the editor:


  • 🚽 Regular

    Return of the Infinite Loading on Quote. (not that it was ever gone)

    http://what.thedailywtf.com/t/the-funny-stuff-thread/2628/365


Log in to reply