nodebb-plugin-calendar - delete post issue
-
Hi Devs,
I am getting the below error on the latest code from github.
Steps to reproduce -
create a new topic.
delete the topic.I should say that the forum uses postgres, so that might be related.
Let me know should you need any more info about this issue.
JJ.Error: message=The "last argument" argument must be of type function, stack=TypeError [ERR_INVALID_ARG_TYPE]: The "last argument" argument must be of type function
at Object.deleteEvent [as method] (util.js:1050:13)
at /nodebb/src/plugins/hooks.js:137:12
at /nodebb/node_modules/async/dist/async.js:3110:16
at eachOfArrayLike (/nodebb/node_modules/async/dist/async.js:1069:9)
at eachOf (/nodebb/node_modules/async/dist/async.js:1117:5)
at Object.eachLimit (/nodebb/node_modules/async/dist/async.js:3172:5)
at fireActionHook (/nodebb/src/plugins/hooks.js:129:9)
at Object.Plugins.fireHook (/nodebb/src/plugins/hooks.js:96:4)
at /nodebb/src/posts/delete.js:45:13
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 iteratorCallback (/nodebb/node_modules/async/dist/async.js:1064:13)
at /nodebb/node_modules/async/dist/async.js:969:16, db=null -
@JJSagan what version of node do you have installed? Try updating to Node 10
-
Latest version of the calendar plugin is only compatible with node 10
-
Yes NodeBB works with Node 10
-
Hi @PitaJ
I updated the running environment to Node 10.
>>node -v v10.11.0
Fresh install of nodebb with nodebb-plugin-calendar.
Creating a post and then deleting it brings the same issue:
error: message=The last argument must be of type Function. Received type object, stack=TypeError [ERR_INVALID_ARG_TYPE]: The last argument must be of type Function. Received type object at Object.deleteEvent [as method] (util.js:1418:13) at nodebb/src/plugins/hooks.js:137:12 at nodebb/node_modules/async/dist/async.js:3110:16 at eachOfArrayLike (nodebb/node_modules/async/dist/async.js:1069:9) at eachOf (nodebb/node_modules/async/dist/async.js:1117:5) at Object.eachLimit (nodebb/node_modules/async/dist/async.js:3172:5) at fireActionHook (nodebb/src/plugins/hooks.js:129:9) at Object.Plugins.fireHook (nodebb/src/plugins/hooks.js:96:4) at nodebb/src/posts/delete.js:45:13 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 iteratorCallback (nodebb/node_modules/async/dist/async.js:1064:13) at nodebb/node_modules/async/dist/async.js:969:16, db=null 2018-10-11T12:57:17.406Z [14863] - info: [app] Shutdown (SIGTERM/SIGINT) Initialised.
Tracing the code a bit, the issue stems from index.js
const postDelete = callbackify(deleteEvent);
Somehow callbackify does not store the callback.
If I look at the old revision of the code, it used to be:
const postDelete = (pid, cb) => deleteEvent(pid).asCallback(cb);
If I use the old code above, deleteEvent does get called properly, but falls on promise issue.
Seems that deleteEvent does not have a callback in its arguments, so that may be the issue.Any idea how to resolve?
Thank you!
JJ. -
Yeah it appears my post delete hook handler is wrong. Can you open an issue on the repository? I'll try fixing it soon.
-
Hi @PitaJ
This issue is strange indeed. The documentation for callbackify does not necessitate a callback, see: https://nodejs.org/api/util.html#util_util_callbackify_original
However, callbackify fails if not provided with a callback
So first, I tried:
const postDelete = (pid, cb) => callbackify(deleteEvent)(pid, cb);
However, since "action:XXX.YYY" does not have a callback to begin with, cb is undefined, thus callbackify fails.
So finally I used an empty callback function:
const postDelete = (pid) => { callbackify(deleteEvent)(pid, function () {} ); };
Its a working solution but I feel somewhat uncomfortable with it.
Pretty sure its NOT "nodebb@github" quality.JJ.
-
Fixed in
[email protected]