'pandoc exited with code null' 解决方案

随着博客文章的不断增加,Hexo生成这些文章需要的时间越来越长,最近居然能卡住几分钟,然后报错:

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

花了不少时间研究到底问题在哪,最终发现是VM的配置太低所致…… :-(

有意思的现象

  • GitHub actions可以成功生成并部署网站
  • 去掉两篇很长的文章,可以生成成功
  • htop 显示swap空间已经全部用完

既然GitHub actions能生成,说明markdown语法没问题。去掉长文章后发现可以生成了,所以考虑到了VM资源问题。观察了下生成过程中的资源使用情况,发现swap不够用了,memory不够大……

解决方案

增大swap空间.

参考 这篇文章,增加一个新的swap文件:

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

完事用htop检查下,确认swap已经增大成功。再hexo g,pandoc不再报错,成功生成网站。


完整错误信息:

======================================== 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