I discovered a bug causing the server crash while using nunjucks template containing error.
how to reproduce
cd /tmp
npx create-foo crash
cd crash
npm install nunjucks express
# create template with an error
cat << EOF > template.njk
{# next line missing '%' before '}' #}
{% block body } <<< this done on purpose
Hi from Template
{% endblock %}
EOF
# Run the server
node server.js
Example app listening at http://localhost:3000
navigate browser to http://localhost:3000
Observe the server crash
logs
/tmp/crash/node_modules/nunjucks/src/environment.js:575
throw err;
^
Template render error: (unknown path)
Template render error: (/tmp/crash/template.njk) [Line 3, Column 1]
expected block end in block statement
at Object._prettifyError (/tmp/crash/node_modules/nunjucks/src/lib.js:36:11)
at /tmp/crash/node_modules/nunjucks/src/environment.js:563:19
at eval (eval at _compile (/tmp/crash/node_modules/nunjucks/src/environment.js:633:18), <anonymous>:19:11)
at /tmp/crash/node_modules/nunjucks/src/environment.js:41:5
at RawTask.call (/tmp/crash/node_modules/asap/asap.js:40:19)
at flush (/tmp/crash/node_modules/asap/raw.js:50:29)
at processTicksAndRejections (internal/process/task_queues.js:77:11)
I discovered a bug causing the server crash while using nunjucks template containing error.
how to reproduce
navigate browser to
http://localhost:3000
Observe the server crashlogs
Expected behavior
Server should not crash within try/catch block