2016-08-01 cooties



  • 1/8 21:27 [25601] - error: TypeError: Cannot read property '0' of undefined
        at /usr/src/app/src/messaging/notifications.js:103:44
        at Array.filter (native)
        at /usr/src/app/src/messaging/notifications.js:102:40
        at /usr/src/app/node_modules/async/lib/async.js:726:13
        at /usr/src/app/node_modules/async/lib/async.js:52:16
        at done (/usr/src/app/node_modules/async/lib/async.js:246:17)
        at /usr/src/app/node_modules/async/lib/async.js:44:16
        at /usr/src/app/node_modules/async/lib/async.js:723:17
        at /usr/src/app/node_modules/async/lib/async.js:167:37
        at /usr/src/app/node_modules/async/lib/async.js:52:16
        at /usr/src/app/node_modules/async/lib/async.js:361:13
        at /usr/src/app/node_modules/async/lib/async.js:52:16
        at async.forEachOf.async.eachOf (/usr/src/app/node_modules/async/lib/async.js:236:30)
        at _asyncMap (/usr/src/app/node_modules/async/lib/async.js:355:9)
        at Object.map (/usr/src/app/node_modules/async/lib/async.js:337:20)
        at /usr/src/app/src/user/settings.js:44:10
        at /usr/src/app/src/database/mongo/hash.js:51:4
        at handleCallback (/usr/src/app/node_modules/mongodb/lib/utils.js:96:12)
        at /usr/src/app/node_modules/mongodb/lib/cursor.js:839:16
        at handleCallback (/usr/src/app/node_modules/mongodb/node_modules/mongodb-core/lib/cursor.js:159:5)
        at setCursorDeadAndNotified (/usr/src/app/node_modules/mongodb/node_modules/mongodb-core/lib/cursor.js:501:3)
        at nextFunction (/usr/src/app/node_modules/mongodb/node_modules/mongodb-core/lib/cursor.js:652:7)
        at Cursor.next [as _next] (/usr/src/app/node_modules/mongodb/node_modules/mongodb-core/lib/cursor.js:693:3)
        at fetchDocs (/usr/src/app/node_modules/mongodb/lib/cursor.js:835:10)
        at /usr/src/app/node_modules/mongodb/lib/cursor.js:858:7
        at handleCallback (/usr/src/app/node_modules/mongodb/node_modules/mongodb-core/lib/cursor.js:159:5)
        at nextFunction (/usr/src/app/node_modules/mongodb/node_modules/mongodb-core/lib/cursor.js:683:5)
        at /usr/src/app/node_modules/mongodb/node_modules/mongodb-core/lib/cursor.js:585:7
        at queryCallback (/usr/src/app/node_modules/mongodb/node_modules/mongodb-core/lib/cursor.js:220:18)
        at Callbacks.emit (/usr/src/app/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:119:3)
        at null.messageHandler (/usr/src/app/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:397:23)
        at Socket.<anonymous> (/usr/src/app/node_modules/mongodb/node_modules/mongodb-core/lib/connection/connection.js:302:22)
        at emitOne (events.js:77:13)
        at Socket.emit (events.js:169:7)
        at readableAddChunk (_stream_readable.js:153:18)
        at Socket.Readable.push (_stream_readable.js:111:10)
        at TCP.onread (net.js:536:20)
    

    Relevant line: https://github.com/NodeBB/NodeBB/blob/11236bb841d21a9fd3ab31131cee3c7b5b040861/src/messaging/notifications.js#L103

    how can JavaScript be so wrong





  • @ben_lubar oh, it was fixed but we haven't updated yet.



  • @ben_lubar said in 2016-08-01 cooties:

    how can JavaScript be so wrong

    Eh...so it doesn't short circuit on a return? I've used languages like that. Or did I not decrypt your cryptic rant?


  • sockdevs

    @boomzilla said in 2016-08-01 cooties:

    Eh...so it doesn't short circuit on a return?

    yes. it does that

    results.userSettings was undefined (kind of but not exactly null) and index was 0

    undefined[0] is an error so exception.

    uncaught exception actually

    uncaught exception means process terminates.... because that's how most languages handle uncaught exceptions in a thread (and node is singlethreaded)



  • @accalia Oh...I didn't notice userData && results.userSettings were different things, I think...uh...I guess I don't get why @ben_lubar would say "how can JavaScript be so wrong" here.


  • sockdevs

    @boomzilla said in 2016-08-01 cooties:

    I guess I don't get why @ben_lubar would say "how can JavaScript be so wrong" here.

    at a guess.... mini blakey rant due to insanity brought on by lack of/excess dwarf fortress?



  • @boomzilla said in 2016-08-01 cooties:

    @accalia Oh...I didn't notice userData && results.userSettings were different things, I think...uh...I guess I don't get why @ben_lubar would say "how can JavaScript be so wrong" here.

    In every other language I use, accessing a nonexistent field of a struct is a compile-time error.



  • @ben_lubar said in 2016-08-01 cooties:

    In every other language I use, accessing a nonexistent field of a struct is a compile-time error.

    Ah OK, fair enough. But...I DON'T HAVE TELEPATHY MAN.


  • sockdevs

    @ben_lubar said in 2016-08-01 cooties:

    @boomzilla said in 2016-08-01 cooties:

    @accalia Oh...I didn't notice userData && results.userSettings were different things, I think...uh...I guess I don't get why @ben_lubar would say "how can JavaScript be so wrong" here.

    In every other language I use, accessing a nonexistent field of a struct is a compile-time error.

    so javascript is the only interpreted language you use?

    you really should braden your programming horizons a bit there.


  • Impossible Mission Players - A

    @ben_lubar said in 2016-08-01 cooties:

    @boomzilla said in 2016-08-01 cooties:

    @accalia Oh...I didn't notice userData && results.userSettings were different things, I think...uh...I guess I don't get why @ben_lubar would say "how can JavaScript be so wrong" here.

    In every other language I use, accessing a nonexistent field of a struct is a compile-time error.

    It's a good thing Javascript is a compiled--- what am I even saying?!



  • @Tsaukpaetra said in 2016-08-01 cooties:

    @ben_lubar said in 2016-08-01 cooties:

    @boomzilla said in 2016-08-01 cooties:

    @accalia Oh...I didn't notice userData && results.userSettings were different things, I think...uh...I guess I don't get why @ben_lubar would say "how can JavaScript be so wrong" here.

    In every other language I use, accessing a nonexistent field of a struct is a compile-time error.

    It's a good thing Javascript is a compiled--- what am I even saying?!

    Yes, JavaScript can be compiled.


  • Impossible Mission Players - A

    @ben_lubar said in 2016-08-01 cooties:

    @Tsaukpaetra said in 2016-08-01 cooties:

    @ben_lubar said in 2016-08-01 cooties:

    @boomzilla said in 2016-08-01 cooties:

    @accalia Oh...I didn't notice userData && results.userSettings were different things, I think...uh...I guess I don't get why @ben_lubar would say "how can JavaScript be so wrong" here.

    In every other language I use, accessing a nonexistent field of a struct is a compile-time error.

    It's a good thing Javascript is a compiled--- what am I even saying?!

    Yes, JavaScript can be compiled.

    I'm not sure if minifying counts as compilation....



  • @Tsaukpaetra said in 2016-08-01 cooties:

    @ben_lubar said in 2016-08-01 cooties:

    @Tsaukpaetra said in 2016-08-01 cooties:

    @ben_lubar said in 2016-08-01 cooties:

    @boomzilla said in 2016-08-01 cooties:

    @accalia Oh...I didn't notice userData && results.userSettings were different things, I think...uh...I guess I don't get why @ben_lubar would say "how can JavaScript be so wrong" here.

    In every other language I use, accessing a nonexistent field of a struct is a compile-time error.

    It's a good thing Javascript is a compiled--- what am I even saying?!

    Yes, JavaScript can be compiled.

    I'm not sure if minifying counts as compilation....

    It has a compile-time error for undeclared fields, so probably.


  • Winner of the 2016 Presidential Election

    You want JavaScript with type safety. ITYM TypeScript.



  • @error said in 2016-08-01 cooties:

    You want JavaScript with type safety. ITYM TypeScript.

    Personally I like gopherjs for that use case. That's why the htmlcleaner plugin doesn't crash from undeclared variables.


  • Winner of the 2016 Presidential Election

    And y'all hated on PHP without realising TRWTF was sneaking around...



  • @ben_lubar Does the compiler look something like this?

    #!/bin/sh
    echo "Error: JavaScript detected" >&2
    exit 1
    

    I guess that could be useful.


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.