#3063·qinglong

[Bug] TypeError: date.includes is not a function after container restart (sequelize 6.37.5 + Node 18+)

Author: nak1liCreated Aug 26, 2026Updated Aug 26, 2026

Bug: TypeError: date.includes is not a function on container restart (QL v2.21.0-debian, sequelize 6.37.5)

Environment

  • Image: whyour/qinglong:2.21.0-debian
  • Verified also affects latest develop branch (v2.21.0-16) — same pinned versions
  • [email protected] + @whyour/[email protected]
  • Node: 18+ (default in this image)

Description

After restarting the QL container (e.g. docker restart qinglong), the PM2 http worker fails to start and keeps restarting in a loop. The web UI is unreachable:

bash
$ curl -s -o /dev/null -w "%{http_code}\n" http://<host>:5700/
000

Error log (from /ql/static/build/pm2/logs/qinglong-out.log)

[error 2026-08-26 12:05:15]: [boot] http worker failed:
TypeError: date.includes is not a function
    at parse (/ql/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/sequelize/src/dialects/sqlite/data-types.js:54:17)
    at Query.applyParsers (/ql/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/sequelize/src/dialects/sqlite/query.js:365:14)
    at <anonymous> (.../sqlite/query.js:152:20)
    at /ql/node_modules/.pnpm/[email protected]/node_modules/lodash/lodash.js:13469:38
    at Function.mapValues (.../lodash.js:13468:7)
    at <anonymous> (.../sqlite/query.js:126:18)
    at Array.map (<anonymous>)
    at Query._handleQueryResponse (.../sqlite/query.js:125:25)
[error ...]: http worker XXX died (1). Restarting...

After the fix this error appears repeatedly during boot until a query lands on a path that triggers applyParsers. Restarting the container reproduces it consistently.

Root cause

[email protected] SQLite dialect code assumes PRAGMA-returned values are strings, but @whyour/[email protected] (and modern Node) can return Number / Date objects. Two specific call sites break:

  1. lib/dialects/sqlite/query.js line 282 (compiled line ~365):

    javascript
    applyParsers(type, value) {
      if (type.includes("(")) {        // ← type can be a Number
        ...
      }
      ...
    }
  2. lib/dialects/sqlite/data-types.js line 39 (compiled line ~54):

    javascript
    class DATE extends BaseTypes.DATE {
      static parse(date, options) {
        if (!date.includes("+")) {     // ← date can be a Date object
          ...
        }
      }
    }

Reproduction

Minimal: pull image and start a container, then restart it:

bash
docker run -d --name ql -p 5700:5700 \
  -v /home/<user>/ql/data:/ql/data \
  whyyour/qinglong:2.21.0-debian
sleep 30 && curl -s -o /dev/null -w "%{http_code}\n" http://localhost:5700/  # 200
docker restart ql
sleep 30 && curl -s -o /dev/null -w "%{http_code}\n" http://localhost:5700/  # 000 / 500
docker logs ql --tail 50 | grep TypeError                                   # present

Suggested fix (verified working)

Wrap with String(...) at both call sites:

diff
--- a/lib/dialects/sqlite/query.js
@@
   applyParsers(type, value) {
-    if (type.includes("(")) {
+    if (String(type).includes("(")) {
       type = type.substr(0, type.indexOf("("));
     }

--- a/lib/dialects/sqlite/data-types.js
@@
   class DATE extends BaseTypes.DATE {
     static parse(date, options) {
-      if (!date.includes("+")) {
+      if (!String(date).includes("+")) {
         return new Date(date + options.timezone);
       }
       return new Date(date);
     }
   }

Both fixes confirmed via pm2 restart all — web UI returns 200 and no further TypeError in logs.

Workaround until patched

Apply the two-line patch via sed inside the container, or commit the patched image so the next pull is already fixed.

Impact

  • Blocks all users who restart the container (DB upgrade, host reboot, etc.)
  • Web UI completely inaccessible until container is recreated from a patched image
  • Cron scheduler also affected since it goes through the same web stack