'pandoc exited with code null' Solution

As the post number increases, Hexo generate posts slower and slower. Recently, it usually generates posts for several minutes and report the following error:

[ERROR][hexo-renderer-pandoc] pandoc exited with code null. at Object._prettifyError (/home/finisky/node_modules/nunjucks/src/lib.js:36:11)

I spent several hours to figure out the issue. Finally, I found the root cause is ... VM memory is too small ... :-(

Observations

  • The GitHub actions is able to sucessfully generate the whole sites
  • Remove the largest markdown file and it works
  • htop shows that the swap space is exhausted

So I guess the issue is caused by the VM's limited resource, especially the RAM size (only 1G).

Solution

The solution is easy: increase the swap space.

Follow this post and create a new swap file:

sudo fallocate -l 512M /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile

Double check the swap space by htop. Now Hexo works again!


The full error message:

======================================== NexT version 8.5.0 Documentation: https://theme-next.js.org ======================================== INFO Start processing FATAL { err: Template render error: (unknown path) Error: [ERROR][hexo-renderer-pandoc] On undefined [ERROR][hexo-renderer-pandoc] pandoc exited with code null. at Object._prettifyError (/home/finisky/node_modules/nunjucks/src/lib.js:36:11) at /home/finisky/node_modules/nunjucks/src/environment.js:563:19 at Template.root [as rootRenderFunc] (eval at _compile (/home/finisky/node_modules/nunjucks/src/environment.js:633:18), :53:3) at Template.render (/home/finisky/node_modules/nunjucks/src/environment.js:552:10) at Environment.renderString (/home/finisky/node_modules/nunjucks/src/environment.js:380:17) at /home/finisky/node_modules/hexo/lib/extend/tag.js:236:16 at tryCatcher (/home/finisky/node_modules/bluebird/js/release/util.js:16:23) at Function.Promise.fromNode.Promise.fromCallback (/home/finisky/node_modules/bluebird/js/release/promise.js:209:30) at Tag.render (/home/finisky/node_modules/hexo/lib/extend/tag.js:235:20) at Object.onRenderEnd (/home/finisky/node_modules/hexo/lib/hexo/post.js:297:22) at /home/finisky/node_modules/hexo/lib/hexo/render.js:79:21 at tryCatcher (/home/finisky/node_modules/bluebird/js/release/util.js:16:23) at Promise._settlePromiseFromHandler (/home/finisky/node_modules/bluebird/js/release/promise.js:547:31) at Promise._settlePromise (/home/finisky/node_modules/bluebird/js/release/promise.js:604:18) at Promise._settlePromise0 (/home/finisky/node_modules/bluebird/js/release/promise.js:649:10) at Promise._settlePromises (/home/finisky/node_modules/bluebird/js/release/promise.js:729:18) at _drainQueueStep (/home/finisky/node_modules/bluebird/js/release/async.js:93:12) at _drainQueue (/home/finisky/node_modules/bluebird/js/release/async.js:86:9) at Async._drainQueues (/home/finisky/node_modules/bluebird/js/release/async.js:102:5) at Immediate.Async.drainQueues (/home/finisky/node_modules/bluebird/js/release/async.js:15:14) at processImmediate (node:internal/timers:464:21) { cause: Template render error: (unknown path) Error: [ERROR][hexo-renderer-pandoc] On undefined [ERROR][hexo-renderer-pandoc] pandoc exited with code null. at Object._prettifyError (/home/finisky/node_modules/nunjucks/src/lib.js:36:11) at /home/finisky/node_modules/nunjucks/src/environment.js:563:19 at Template.root [as rootRenderFunc] (eval at _compile (/home/finisky/node_modules/nunjucks/src/environment.js:633:18), :53:3) at Template.render (/home/finisky/node_modules/nunjucks/src/environment.js:552:10) at Environment.renderString (/home/finisky/node_modules/nunjucks/src/environment.js:380:17) at /home/finisky/node_modules/hexo/lib/extend/tag.js:236:16 at tryCatcher (/home/finisky/node_modules/bluebird/js/release/util.js:16:23) at Function.Promise.fromNode.Promise.fromCallback (/home/finisky/node_modules/bluebird/js/release/promise.js:209:30) at Tag.render (/home/finisky/node_modules/hexo/lib/extend/tag.js:235:20) at Object.onRenderEnd (/home/finisky/node_modules/hexo/lib/hexo/post.js:297:22) at /home/finisky/node_modules/hexo/lib/hexo/render.js:79:21 at tryCatcher (/home/finisky/node_modules/bluebird/js/release/util.js:16:23) at Promise._settlePromiseFromHandler (/home/finisky/node_modules/bluebird/js/release/promise.js:547:31) at Promise._settlePromise (/home/finisky/node_modules/bluebird/js/release/promise.js:604:18) at Promise._settlePromise0 (/home/finisky/node_modules/bluebird/js/release/promise.js:649:10) at Promise._settlePromises (/home/finisky/node_modules/bluebird/js/release/promise.js:729:18) at _drainQueueStep (/home/finisky/node_modules/bluebird/js/release/async.js:93:12) at _drainQueue (/home/finisky/node_modules/bluebird/js/release/async.js:86:9) at Async._drainQueues (/home/finisky/node_modules/bluebird/js/release/async.js:102:5) at Immediate.Async.drainQueues (/home/finisky/node_modules/bluebird/js/release/async.js:15:14) at processImmediate (node:internal/timers:464:21), isOperational: true } } Something's wrong. Maybe you can find the solution here: %s https://hexo.io/docs/troubleshooting.html