NodeBB-Community / nodebb-plugin-custom-pages

Allows you to add as many new pages as you like to your NodeBB forum
BSD 2-Clause "Simplified" License
39 stars 24 forks source link

Fixes crash when creating sub-routes due to incompatible mkdirp #62

Closed nefarius closed 4 years ago

nefarius commented 4 years ago

My in-place upgraded NodeBB v1.13.3 installation suddenly crashed, as did a fresh installation with only this plugin installed. The shipped version/edition/fork of mkdirp is incompatible with the API the plugin uses and causes the following error resulting in crash and boot loop:

playground.xxxx-app | 2020-05-20T17:15:28.664Z [4567/195] - error: uncaughtException: invalid options argument
playground.xxxx-app | TypeError: invalid options argument
playground.xxxx-app |     at optsArg (/usr/src/app/node_modules/mkdirp/lib/opts-arg.js:13:11)
playground.xxxx-app |     at mkdirp (/usr/src/app/node_modules/mkdirp/index.js:11:10)
playground.xxxx-app |     at /usr/src/app/node_modules/nodebb-plugin-custom-pages/library.js:244:6
playground.xxxx-app |     at processTicksAndRejections (internal/process/task_queues.js:84:21) {"error":{},"stack":"TypeError: invalid options argument\n    at optsArg (/usr/src/app/node_modules/mkdirp/lib/opts-arg.js:13:11)\n    at mkdirp (/usr/src/app/node_modules/mkdirp/index.js:11:10)\n    at /usr/src/app/node_modules/nodebb-plugin-custom-pages/library.js:244:6\n    at processTicksAndRejections (internal/process/task_queues.js:84:21)","exception":true,"date":"Wed May 20 2020 17:15:28 GMT+0000 (Coordinated Universal Time)","process":{"pid":195,"uid":0,"gid":0,"cwd":"/usr/src/app","execPath":"/usr/local/bin/node","version":"v12.16.3","argv":["/usr/local/bin/node","/usr/src/app/app.js"],"memoryUsage":{"rss":126791680,"heapTotal":72941568,"heapUsed":68767744,"external":1734994}},"os":{"loadavg":[0.595703125,0.75439453125,0.6005859375],"uptime":385709},"trace":[{"column":11,"file":"/usr/src/app/node_modules/mkdirp/lib/opts-arg.js","function":"optsArg","line":13,"method":null,"native":false},{"column":10,"file":"/usr/src/app/node_modules/mkdirp/index.js","function":"mkdirp","line":11,"method":null,"native":false},{"column":6,"file":"/usr/src/app/node_modules/nodebb-plugin-custom-pages/library.js","function":null,"line":244,"method":null,"native":false},{"column":21,"file":"internal/process/task_queues.js","function":"processTicksAndRejections","line":84,"method":null,"native":false}]}

This change uses mkdirp-classic, which provides the "legacy" compatible API without downgrading mkdirp.

barisusakli commented 4 years ago

we should fix this properly by adding latest mkdirp dependency into package.json and fixing the mkdirp call in the plugin

barisusakli commented 4 years ago

Released v1.2.0, please let me know if you have any issues.

nefarius commented 4 years ago

Works, thank you!