recentreplies.js Error causing problems

Solved Technical Support
  • #1

    General information:
    NodeBB-Version: v1.10.2
    MongoDB: v3.6.8
    NodeJS: v8.12.0
    npm: 6.4.1
    OS: Ubuntu 16.04.5 LTS
    Language: German (de-DE)
    Installation directory: /srv/nodebb/
    Guide used:

    This error caused NodeBB to not start at all:

    2018-11-12T15:37:37.229Z [11150] - error:  message=Cannot read property 'forEach' of undefined, stack=TypeError: Cannot read property 'forEach' of undefined
        at getPostsRecursive (/srv/nodebb/src/categories/recentreplies.js:188:18)
        at /srv/nodebb/src/categories/recentreplies.js:193:4
        at Array.forEach (<anonymous>)
        at getPostsRecursive (/srv/nodebb/src/categories/recentreplies.js:192:21)
        at /srv/nodebb/src/categories/recentreplies.js:193:4
        at Array.forEach (<anonymous>)
        at getPostsRecursive (/srv/nodebb/src/categories/recentreplies.js:192:21)
        at /srv/nodebb/src/categories/recentreplies.js:176:4
        at Array.forEach (<anonymous>)
        at bubbleUpChildrenPosts (/srv/nodebb/src/categories/recentreplies.js:171:16)
        at /srv/nodebb/src/categories/recentreplies.js:104:5
        at nextTask (/srv/nodebb/node_modules/async/dist/async.js:5324:14)
        at next (/srv/nodebb/node_modules/async/dist/async.js:5331:9)
        at /srv/nodebb/node_modules/async/dist/async.js:969:16
        at /srv/nodebb/node_modules/async/dist/async.js:473:16
        at next (/srv/nodebb/node_modules/async/dist/async.js:5329:29)

    I had to comment out following line from /srv/nodebb/src/categories/recentreplies.js (line 188-196) to make my NodeBB run:

    function getPostsRecursive(category, posts) {
    //              category.posts.forEach(function (p) {
    //                      posts.push(p);
    //              });
    //              category.children.forEach(function (child) {
    //                      getPostsRecursive(child, posts);
    //              });

    I'm not sure if this has anything to do with it, but when clicking on certain flags, following error happens. I think a user flagged his own message (somehow?!), however I'm not sure because I can't click on the flag without crashing NodeBB:

    2018-11-12T15:46:57.149Z [11883] - error:  message=Cannot convert undefined or null to object, stack=TypeError: Cannot convert undefined or null to object
        at Function.keys (<anonymous>)
        at /srv/nodebb/src/controllers/mods.js:140:26
        at Array.reduce (<anonymous>)
        at /srv/nodebb/src/controllers/mods.js:136:41
        at /srv/nodebb/node_modules/async/dist/async.js:3888:9
        at /srv/nodebb/node_modules/async/dist/async.js:473:16
        at iterateeCallback (/srv/nodebb/node_modules/async/dist/async.js:992:24)
        at /srv/nodebb/node_modules/async/dist/async.js:969:16
        at /srv/nodebb/node_modules/async/dist/async.js:3885:13
        at /srv/nodebb/node_modules/async/dist/async.js:473:16
        at next (/srv/nodebb/node_modules/async/dist/async.js:5329:29)
        at /srv/nodebb/node_modules/async/dist/async.js:969:16
        at Object.Categories.buildForSelectCategories (/srv/nodebb/src/categories.js:369:2)
        at /srv/nodebb/src/categories.js:341:15
        at nextTask (/srv/nodebb/node_modules/async/dist/async.js:5324:14)
        at next (/srv/nodebb/node_modules/async/dist/async.js:5331:9)

    It seems as this is a database problem because I've retested this on a fresh NodeBB installation (while copying and reusing the database). I'm not that into Databases, so please let me know if I should post any command-outputs here for additional information.

  • #3

    @baris Thank you so much (especially for your fast response). That commit fixed everything!

    Regarding the second issue, is there any possible fix? I'd really appreciate it.

  • GNU/Linux

    Yes, the second issue was fixed and is in latest master at the moment

  • #5

    @julian You're a real magician. This is crazy fast support. I'm absolutely stunned by NodeBB now. Not going to consider switching anymore because you fixed it. Thank you sooo much!

    Could you post the commit-URL so I can edit it locally on my release-install?

  • GNU/Linux

    Yes, you can cherry-pick this sha to get it into your NodeBB

    Edit: You just happened to catch me online at the same time, hah. The flag issue is also resolved from a couple days ago, so it wasn't done just now πŸ˜‰

  • #7

    @julian Alright, but if you made me aware of the commit/fix. And very fast.

    I'll fix some horrible German translations (especially in the GDPR which is critical) as a favor. I hope Transifex gets merged soon (regarding:

    You saved my 150k community from switching to phpBB πŸ˜›

  • #8

    Hi, I'm getting a similar error message Cannot read property 'forEach' of undefined but in authentication.js:63:19. It started after I installed a couple of sso plugins: Facebook, Twitter, Discord, and Google. The cherry pick did not help me 😧

  • NodeBB

    @PJ-Legendre please post the stack trace from logs/output.log

  • #10

    Thank you for getting back so quickly. Here it is:

    NodeBB v1.10.2 Copyright (C) 2013-2014 NodeBB Inc.
    This program comes with ABSOLUTELY NO WARRANTY.
    This is free software, and you are welcome to redistribute it under certain conditions.
    For the full license, please visit:
    Clustering enabled: Spinning up 1 process(es).
    2018-11-16T15:34:42.545Z [6029] - ^[[32minfo^[[39m: Initializing NodeBB v1.10.2
    2018-11-16T15:34:45.317Z [6029] - ^[[32minfo^[[39m: [] Restricting access to origin:*
    2018-11-16T15:34:45.956Z [6029] - ^[[31merror^[[39m: [sso-discord] Cliend ID and Client Secret required (library.js:36)
    2018-11-16T15:34:41.422Z [5991] - ^[[31merror^[[39m:  message=Cannot read property 'forEach' of undefined, stack=TypeError: Cannot read property 'forEach' of undefined
        at /home/myuser/nodebb/src/routes/authentication.js:63:19
        at nextTask (/home/myuser/nodebb/node_modules/async/dist/async.js:5324:14)
        at next (/home/myuser/nodebb/node_modules/async/dist/async.js:5331:9)
        at /home/myuser/nodebb/node_modules/async/dist/async.js:969:16
        at /home/myuser/nodebb/node_modules/async/dist/async.js:473:16
        at /home/myuser/nodebb/node_modules/async/dist/async.js:2521:9
        at /home/myuser/nodebb/node_modules/async/dist/async.js:473:16
        at replenish (/home/myuser/nodebb/node_modules/async/dist/async.js:1006:25)
        at iterateeCallback (/home/myuser/nodebb/node_modules/async/dist/async.js:995:17)
        at /home/myuser/nodebb/node_modules/async/dist/async.js:969:16
        at /home/myuser/nodebb/node_modules/async/dist/async.js:2518:13
        at Object.Facebook.getStrategy (/home/myuser/nodebb/node_modules/nodebb-plugin-sso-facebook/library.js:140:3)
        at /home/myuser/nodebb/node_modules/nodebb-plugin-sso-facebook/library.js:72:14
        at /home/myuser/nodebb/node_modules/nodebb-plugin-sso-facebook/library.js:65:4
        at /home/myuser/nodebb/src/meta/settings.js:14:3
        at /home/myuser/nodebb/src/database/mongo/hash.js:78:4
    2018-11-16T15:34:41.426Z [5991] - ^[[32minfo^[[39m: [app] Shutdown (SIGTERM/SIGINT) Initialised.
    2018-11-16T15:34:41.427Z [5991] - ^[[31merror^[[39m:  message=Not running, stack=Error: Not running
        at Server.<anonymous> (net.js:1517:12)
        at Server.g (events.js:292:16)
        at emitNone (events.js:91:20)
        at Server.emit (events.js:185:7)
        at emitCloseNT (net.js:1568:8)
        at _combinedTickCallback (internal/process/next_tick.js:77:11)
        at Immediate._tickCallback (internal/process/next_tick.js:104:9)
        at runCallback (timers.js:672:20)
        at tryOnImmediate (timers.js:645:5)
        at processImmediate [as _immediateCallback] (timers.js:617:5)
  • NodeBB

    I added a check so nodebb doesn't crash here You possibly activated an sso plugin that is not using filter:auth.init properly. Which sso plugins do you have?

  • NodeBB

    Yes, it needs to be updated so it doesnt pass back undefined to hook callback.

  • #14

    I will notify the plugin's creator, thank you.

Suggested Topics

| | | |