Redactor crashes NodeBB

Technical Support
  • Hi Devs,
    It seems that Redactor may have an issue with the latest master.

    When opened, it crashes nodebb with the below. The issue can be reproduced, again and again.
    I also got this during build - perhaps that's related:

    Browserslist: caniuse-lite is outdated. Please run next command `yarn upgrade caniuse-lite browserslist`

    Crash log:

    2018-12-24 - error: uncaughtException: Cannot read property 'children' of undefined
    TypeError: Cannot read property 'children' of undefined
        at nodebb/node_modules/nodebb-plugin-composer-default/websockets.js:128:73
        at Array.filter (<anonymous>)
        at nodebb/node_modules/nodebb-plugin-composer-default/websockets.js:119:44
        at nextTask (nodebb/node_modules/async/dist/async.js:5324:14)
        at next (nodebb/node_modules/async/dist/async.js:5331:9)
        at nodebb/node_modules/async/dist/async.js:969:16
        at nodebb/node_modules/async/dist/async.js:3888:9
        at nodebb/node_modules/async/dist/async.js:473:16
        at iterateeCallback (nodebb/node_modules/async/dist/async.js:992:24)
        at nodebb/node_modules/async/dist/async.js:969:16
        at nodebb/node_modules/async/dist/async.js:3885:13
        at nodebb/src/privileges/categories.js:98:5
        at nodebb/node_modules/async/dist/async.js:473:16
        at next (nodebb/node_modules/async/dist/async.js:5329:29)
        at nodebb/node_modules/async/dist/async.js:969:16
        at nodebb/src/privileges/helpers.js:81:4 {"error":{},"stack":"Type
  • This issue may be related to permission.
    Normal user with permission crashes nodebb upon redactor opening, while Admin does not.

  • Hi @baris ,

    The category is defined. The problem is the access to the array cidToCategory.
    I reviewed its content with the debugger, and the c.parent.cid cannot be used to access it:
    cidToCategory does not have linear index that matches the internal cid:

    Index: Data:
    1: {cid: 1, icon: "hidden", link: "", …}
    2: {cid: 31, icon: "hidden", link:…}
    3: {cid: 9, icon: …}
    4: {cid: 37, icon: "hidden", link: …}

    Furthermore, Some parts of the array is undefined.

    This is the definition of cidToCategory :

    var cidToCategory = _.zipObject(cids, results.categories);

    The bad access occures in line 128, where the cid is used:

    cidToCategory[c.parent.cid].children = cidToCategory[c.parent.cid].children.filter(child => {
    						return child.cid !== c.cid;
  • @JJSagan Hmm that's definitely weird cidToCategory should be an object with the keys being category ids.

    On my environment I get this.

    { '1':
       { bgColor: '#fda34b',
         cid: 1,
         class: 'col-md-3 col-xs-6',
         color: '#fff',
         description: 'Announcements regarding our community',
         descriptionParsed: '<p>Announcements regarding our community</p>\n',
         disabled: 0,
         icon: 'fa-bullhorn',
         imageClass: 'cover',
         isSection: 0,
         link: '',
         name: 'Announcements',
         numRecentReplies: 1,
         order: 1,
         parentCid: 0,
         post_count: 33,
         slug: '1/announcements',
         topic_count: 5,
         totalPostCount: 33,
         totalTopicCount: 5,
         children: [],
         parent: undefined },
       { bgColor: '#59b3d0',
         cid: 2,
         class: 'col-md-3 col-xs-6',
         color: '#fff',
         description: 'A place to talk about whatever you want',
         descriptionParsed: '<p>A place to talk about whatever you want</p>\n',
         disabled: 0,
         icon: 'fa-comments-o',
         imageClass: 'cover',
         isSection: 0,
         link: '',
         name: 'General Discussion',
         numRecentReplies: 1,
         order: 2,
         parentCid: 0,
         post_count: 20,
         slug: '2/general-discussion',
         topic_count: 7,
         totalPostCount: 20,
         totalTopicCount: 7,
         children: [ [Object] ],
         parent: undefined },
       { bgColor: '#86ba4b',
         cid: 3,
         class: 'col-md-3 col-xs-6',
         color: '#fff',
         description: 'Blog posts from individual members',
         descriptionParsed: '<p>Blog posts from individual members</p>\n',
         disabled: 0,
         icon: 'fa-newspaper-o',
         imageClass: 'cover',
         isSection: 0,
         link: '',
         name: 'Blogs',
  • Hi @baris ,

    From what I see, the categories on my setup are well defined and working. I also made a quick check with group privileges - to make sure access is granted to the target category, and it looks like we are ok.

    I may have, over time, obsoleted several categories, and maybe later returned some or all to active duty. Thus, the cid array may not be perfectly "linear".

    Another direction: I am using postgress, so maybe the array that is fetched from the DB is not sorted. I hope @Ben-Lubar might be able to shed some light here.

    Thanks again for looking into this! highly appreciated.

  • Can you put a console.log(cids, cidToCategory); right after the _.zipObject call and let me know the output? It shouldn't matter if the cids array is linear, as long as all the items in it are valid category ids.

  • @baris said in Redactor crashes NodeBB:

    console.log(cids, cidToCategory);

    It looks good. As far as I can tell, all items are valid. The issue is that the array index (below, for example first line: 37), does not matches internal cid (below, 2nd line: 10). Thus, the array may not be accessed with the c.parent.cid.

    Perhaps we need to sort the array first, or use filter?

    Console.log output:

     { cid: 10,
       icon: 'hidden',
       link: '',
    } },
     { cid: 34,
       icon: 'hidden',
       link: '',
    } },
     { cid: 40,
       icon: 'hidden',
       link: '',
  • Yep, that's the issue, I am working on a fix.

  • Should be fixed on latest master, let me know the new output and if all cids match the internal cid.

  • Hi @baris
    Your latest code fixes the issue at hand.
    Thank you so much!

Suggested Topics

  • 1 Votes
    8 Posts

    I have test with your first solution @baris

    Result :

    the user who sends the message does not see it displayed. For this he must refresh the page with F5 = no refresh of the chat. The other users do receive a notification, which the oin does not want.

    --> The global chat should refresh itself when sending a message from anyone without notifying the members of the chat room

  • 1 Votes
    1 Posts

    1st of all i'm new to Nginx, and this is the 1st time i'm really setting up NodeBB. So pls forgive me when i'm asking basic dummy questions.

    Basically followed this
    using Ubunt 20. So far so good with the installation.

    The folder structure looks like this in the server:

    /home/user/abcde/index.html /root/nodebb (This might be a mistake but ...)

    Eventually index.html will have a hyperlink which links to the NodeBB forum.

    Right now the /etc/nginx/nginx.conf has a block like this, and index.html does load fine in browser

    server { server_name; location / { root /home/user/abcde; } }

    My question is: how to modify nginx.conf so it can load the NodeBB as well ?
    Again the final goal is ppl can access NodeBB from its link from index.html.

    Thanks very much for your help !

  • 0 Votes
    6 Posts

    @rahmon is the repeated http in the actual file or is that a copy-paste error? It should only be one.

    When you go to access your site, do you enter in your browser? If not, you should use whatever URL you actually access your site at in that field instead.

    For instance, we have in our "url" field in config.json.

  • 0 Votes
    1 Posts

    Since some weeks, possibly after upgrading to 1.4.5 the modemailer causes nodebb to restart.
    Does anybody else have that problem?

    Here are the log entries:

    27/4 06:36:52 [19664] - error: TypeError: this.message.messageId is not a function at MailComposer.compile (/home/forum/nodebb/node_modules/nodemailer/node_modules/mailcomposer/lib/mailcomposer.js:90:18) at module.exports (/home/forum/nodebb/node_modules/nodemailer/node_modules/mailcomposer/lib/mailcomposer.js:7:35) at Nodemailer.<anonymous> (/home/forum/nodebb/node_modules/nodemailer/lib/nodemailer.js:286:24) at Nodemailer._processPlugins (/home/forum/nodebb/node_modules/nodemailer/lib/nodemailer.js:352:16) at Nodemailer.sendMail (/home/forum/nodebb/node_modules/nodemailer/lib/nodemailer.js:280:10) at Object.Emailer.sendViaFallback (/home/forum/nodebb/src/emailer.js:136:21) at /home/forum/nodebb/src/emailer.js:114:14 at fn (/home/forum/nodebb/node_modules/async/lib/async.js:746:34) at /home/forum/nodebb/node_modules/async/lib/async.js:1213:16 at /home/forum/nodebb/node_modules/async/lib/async.js:166:37 at /home/forum/nodebb/node_modules/async/lib/async.js:706:43 at /home/forum/nodebb/node_modules/async/lib/async.js:167:37 at Immediate.<anonymous> (/home/forum/nodebb/node_modules/async/lib/async.js:1206:34) at runCallback (timers.js:666:20) at tryOnImmediate (timers.js:639:5) at processImmediate [as _immediateCallback] (timers.js:611:5) 27/4 06:36:52 [19664] - info: [app] Shutdown (SIGTERM/SIGINT) Initialised.
  • 0 Votes
    5 Posts

    @baris said:

    The error message is telling you that it can't access/save the file. Make sure the user you are running the commands has the proper permissions.

    I wondered that too, I was using a user I specifically created for this task in order to not use the root user as I thought it was not a good practice to do. Especially since the instructions indicate a sudo user. Usually I can figure out permission issues, but for some reason I have not been able to solve this one. The installation does get further when using the root user, so there is definitely a permission issue.

    The error I get now is related to the connection of the Redis database. I get a connection refused error when using the IP of the server.

    The abort error shows the IP address and default port number so I have no idea how to connect the database.

    Here's the latest console information ...

    [email protected] node_modules/connect-redis └── [email protected] ([email protected]) 25/4 19:08 [21628] - info: Populating database with default configs, if not already set... 25/4 19:08 [21628] - error: Error: Redis connection to myserverIP:6379 failed - connect ECONNREFUSED at RedisClient.flush_and_error (/mydomainpath/nodebb/node_modules/redis/index.js:142:13) at RedisClient.on_error (/mydomainpath/nodebb/node_modules/redis/index.js:180:10) at Socket.<anonymous> (/mydomainpath/nodebb/node_modules/redis/index.js:95:14) at Socket.EventEmitter.emit (events.js:95:17) at net.js:441:14 at process._tickCallback (node.js:415:13) 25/4 19:08 [21628] - warn: NodeBB Setup Aborted. Redis connection to myserverIP:6379 failed - connect ECONNREFUSED

    Thanks ... Pops