recentreplies.js Error causing problems
-
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: https://docs.nodebb.org/installing/os/ubuntu/
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.
-
For the first error see this, https://github.com/NodeBB/NodeBB/commit/157a7d1f0ed082f20345b9523ab4826dab1483d0
The second issue sounds like it is related to this https://github.com/NodeBB/NodeBB/issues/6925
-
@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?
-
@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: https://community.nodebb.org/topic/13269/missing-translation-string-user-watched_categories/).
You saved my 150k community from switching to phpBB
-
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 -
@PJ-Legendre please post the stack trace from
logs/output.log
-
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: http://www.gnu.org/copyleft/gpl.html Clustering enabled: Spinning up 1 process(es). 2018-11-16T15:34:42.545Z [6029] - ^[[32minfo^[[39m: Initializing NodeBB v1.10.2 https://forum.mydomain.com 2018-11-16T15:34:45.317Z [6029] - ^[[32minfo^[[39m: [socket.io] Restricting access to origin: https://forum.mydomain.com:* 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)
-
Thanks so much for the fix! I activated these plugins:
- https://github.com/julianlam/nodebb-plugin-sso-facebook
- https://github.com/julianlam/nodebb-plugin-sso-google
- https://github.com/julianlam/nodebb-plugin-sso-twitter
- https://github.com/NathanSMB/nodebb-plugin-sso-discord
I assume the culprit might be the discord one?
-
I will notify the plugin's creator, thank you.