TypeError: Cannot read properties of undefined (reading 'split')


  • Around a month ago I did upgrade NodeBB (not sure from which version, to 2.4 or 2.2) and also Node (from 16 I think to v18.7.0), and after that I'm getting this error:

    TypeError: Cannot read properties of undefined (reading 'split')
    

    This is what I see in web browser.
    This is what I get in nginx's error log:

    2022/08/14 15:57:08 [error] 674481#674481: *77854 upstream prematurely closed connection while reading response header from upstream, client: MY_IP, server: pythonforum.ir, request: "GET /post/1881 HTTP/1.1", upstream: "http://127.0.0.1:8080/post/1881", host: "pythonforum.ir"
    2022/08/14 15:57:09 [error] 674481#674481: *77854 connect() failed (111: Connection refused) while connecting to upstream, client: MY_IP, server: pythonforum.ir, request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:8080/favicon.ico", host: "pythonforum.ir", referrer: "https://pythonforum.ir/post/1881"
    

    I'm running nodebb as a systemd service and it is up.
    This is /home/path/to/nodebb log:

    2022-08-14T11:34:15.563Z [8080/676608] - error: uncaughtException: Cannot read properties of undefined (reading 'split')
    TypeError: Cannot read properties of undefined (reading 'split')
        at helpers.buildBodyClass (/home/path/to/src/middleware/helpers.js:60:46)
        at exports.send404 (/home/path/to/src/controllers/404.js:62:22)
        at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {"date":"Sun Aug 14 2022 16:04:15 GMT+0430 (Iran Daylight Time)","error":{},"exception":true,"os":{"loadavg":[0.06,0.09,0.06],"uptime":2700726.25},"process":{"argv":["/usr/bin/node","/home/path/to/app.js"],"cwd":"/home/path/to","execPath":"/usr/bin/node","gid":0,"memoryUsage":{"arrayBuffers":19074166,"external":21101205,"heapTotal":77463552,"heapUsed":72795168,"rss":142405632},"pid":676608,"uid":0,"version":"v18.7.0"},"stack":"TypeError: Cannot read properties of undefined (reading 'split')\n    at helpers.buildBodyClass (/home/path/to/src/middleware/helpers.js:60:46)\n    at exports.send404 (/home/path/to/src/controllers/404.js:62:22)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)","trace":[{"column":46,"file":"/home/path/to/src/middleware/helpers.js","function":"helpers.buildBodyClass","line":60,"method":"buildBodyClass","native":false},{"column":22,"file":"/home/path/to/src/controllers/404.js","function":"exports.send404","line":62,"method":"send404","native":false},{"column":5,"file":"node:internal/process/task_queues","function":"process.processTicksAndRejections","line":95,"method":"processTicksAndRejections","native":false}]}
    2022-08-14T11:34:15.572Z [8080/676608] - error: TypeError: Cannot read properties of undefined (reading 'split')
        at helpers.buildBodyClass (/home/path/to/src/middleware/helpers.js:60:46)
        at exports.send404 (/home/path/to/src/controllers/404.js:62:22)
        at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    2022-08-14T11:34:15.573Z [8080/676608] - info: [app] Shutdown (SIGTERM/SIGINT) Initialised.
    2022-08-14T11:34:15.583Z [8080/676608] - info: [app] Web server closed to connections.
    2022-08-14T11:34:15.600Z [8080/676608] - info: [app] Live analytics saved.
    2022-08-14T11:34:15.622Z [8080/676608] - info: [app] Database connection closed.
    2022-08-14T11:34:15.623Z [8080/676608] - info: [app] Shutdown complete.
    [cluster] Child Process (676608) has exited (code: 1, signal: null)
    [cluster] Spinning up another process...
    2022-08-14T11:34:16.643Z [8080/676900] - info: Initializing NodeBB v2.4.1 https://pythonforum.ir
    

    Do you help me what is wrong with it? I tried many thing, like using old backup for both database and files but it did not help me.

  • NodeBB Admin

    Seems like nodebb can't find the meta.config object on your instance on this line https://github.com/NodeBB/NodeBB/blob/master/src/middleware/helpers.js#L60

    Can you check the database nodebb is connecting and look for the config object? In mongodb the command would be db.objects.findOne({_key: "config"});


  • @baris this is my helpers.js:

    parts.push(`theme-${meta.config['theme:id'].split('-')[2]}`);
    

    This is git status:

    [email protected]:/home/nodebb/src/middleware# git status
    On branch v2.x
    Your branch is up to date with 'origin/v2.x'.
    
    nothing to commit, working tree clean
    

    There's nothing difference between my files are git.


  • Database connection works fine, I checked it and tried with both Mongo Compass, and mongo command with username and password authentication.


  • Any updates?

  • Global Moderator Plugin & Theme Dev

    @inna please execute the mongo command baris provided, and post the result


  • Hi, this is the result, it's null:

    [email protected]:/home/nodebb# mongo
    MongoDB shell version v4.0.28
    connecting to: mongodb://127.0.0.1:27017/?gssapiServiceName=mongodb
    Implicit session: session { "id" : UUID("SOMEID") }
    MongoDB server version: 4.0.28
    
    > db.objects.findOne({_key: "config"});
    null
    >
    
  • Global Moderator Plugin & Theme Dev

    @inna you'll need to select the NodeBB database then run the command.


  • Hi, that's it:

    > use nodebb
    switched to db nodebb
    > db.objects.findOne({_key: "config"});
    null
    

  • @inna said in TypeError: Cannot read properties of undefined (reading 'split'):

    Hi, that's it:

    > use nodebb
    switched to db nodebb
    > db.objects.findOne({_key: "config"});
    null
    

    That's when authorization is disabled and I get the above output.

    The following is when authorization is enabled:

    > db.objects.findOne({_key: "config"});
    2022-08-20T21:35:32.379+0430 E QUERY    [js] Error: error: {
            "ok" : 0,
            "errmsg" : "not authorized on test to execute command { find: \"objects\", filter: { _key: \"config\" }, limit: 1.0, singleBatch: true, lsid: { id: UUID(\"f06f4d62-6d71-4f1d-b23c-7e6293adf942\") }, $db: \"test\" }",
            "code" : 13,
            "codeName" : "Unauthorized"
    } :
    [email protected]/mongo/shell/utils.js:25:13
    [email protected]/mongo/shell/query.js:708:1
    [email protected]/mongo/shell/query.js:113:28
    [email protected]/mongo/shell/query.js:288:5
    [email protected]/mongo/shell/collection.js:260:10
    @(shell):1:1
    

Suggested Topics

  • 5
  • 2
  • 4
  • 1
  • 21
| | |

© 2014 – 2022 NodeBB, Inc. — Made in Canada.