0
  • Node.js 版本:v12.13.1。
  • 操作系统:Microsoft Windows 10 Pro,版本:10.0.18362 Build 18362
  • NPM 包

    "agenda": "^2.0.2",
    "appmetrics-dash": "^5.0.0",
    "avro-schema-registry": "^1.5.1",
    "avsc": "^5.4.16",
    "await-to-js": "^2.1.1",
    "bluebird": "^3.5.3",
    "body-parser": "^1.18.3",
    "dd-trace": "^0.12.1",
    "debug": "^4.1.0",
    "express": "^4.16.4",
    "express-server-status": "^1.0.3",
    "express-status-monitor": "^1.2.6",
    "json-2-csv": "^3.5.2",
    "kafkajs": "^1.11.0",
    "lodash": "^4.17.11",
    "moment": "^2.24.0",
    "mongodb": "^3.1.8",
    "mongoose": "^5.3.3",
    "mongoose-auto-increment": "^5.0.1",
    "qs": "6.9.0",
    "request": "^2.88.0",
    "request-promise": "^4.2.2",
    "sha256": "^0.2.0",
    "slack-node": "^0.1.8",
    "socket.io": "^2.2.0"
    

我只运行议程作业。几乎所有作业都在从其他 API 同步数据并将所有数据保存到 MongoDB。有时在我启动项目一段时间后,我会收到此错误:

(node:26128) TimeoutOverflowWarning: 2591699977 不适合 32 位有符号整数。在 jobProcessing (C:\Users\mailb\OneDrive\Desktop\DST\custom- market\node_modules\agenda\lib\utils\process-jobs.js:258:7) 在 C:\Users\mailb\OneDrive\Desktop\DST\custom-market\node_modules\agenda\lib\utils\process-jobs。 js:217:9 在 C:\Users\mailb\OneDrive\Desktop\DST\custom-market\node_modules\agenda\lib\agenda\find-and-lock-next-job.js:81:7 在 C:\ Users\mailb\OneDrive\Desktop\DST\custom-market\node_modules\agenda\node_modules\mongodb\lib\utils.js:414:17 在 C:\Users\mailb\OneDrive\Desktop\DST\custom-market\node_modules \agenda\node_modules\mongodb\lib\utils.js:401:11 在 ClientSession.endSession (C:

4

1 回答 1

0

我最终安装了“议程”:“2.2.0”版本。它表明我在我没有抛出错误的一个实例中犯了一个错误,它使工作无限地进行。

我建议您尝试相同的方法并使用 --trace-warnings 运行您的服务器。

npm install --save agenda@2.2.0
node --trace-warnings yournodejsapp

然后,只需查看日志,它将输出错误发生的位置。修复错误,你会很好:-)

供参考,

如果您查看发生错误的议程源代码。

// If the 'nextRunAt' time is older than the current time, run the job
// Otherwise, setTimeout that gets called at the time of 'nextRunAt'
if (job.attrs.nextRunAt < now) {
  debug('[%s:%s] nextRunAt is in the past, run the job immediately', job.attrs.name, job.attrs._id);
  runOrRetry();
} else {
  const runIn = job.attrs.nextRunAt - now;
  debug('[%s:%s] nextRunAt is in the future, calling setTimeout(%d)', job.attrs.name, job.attrs._id, runIn);
  setTimeout(runOrRetry, runIn);
}

/**
 * Internal method that tries to run a job and if it fails, retries again!
 * @returns {undefined}
 */
async function runOrRetry() {
  if (self._processInterval) {
    const job = jobQueue.pop();
    const jobDefinition = definitions[job.attrs.name];
    if (jobDefinition.concurrency > jobDefinition.running && self._runningJobs.length < self._maxConcurrency) {
      // Get the deadline of when the job is not supposed to go past for locking
      const lockDeadline = new Date(Date.now() - jobDefinition.lockLifetime);

      // This means a job has "expired", as in it has not been "touched" within the lockoutTime
      // Remove from local lock
      // NOTE: Shouldn't we update the 'lockedAt' value in MongoDB so it can be picked up on restart?
      if (job.attrs.lockedAt < lockDeadline) {
        debug('[%s:%s] job lock has expired, freeing it up', job.attrs.name, job.attrs._id);
        self._lockedJobs.splice(self._lockedJobs.indexOf(job), 1);
        jobDefinition.locked--;
        jobProcessing();
        return;
      }

      // Add to local "running" queue
      self._runningJobs.push(job);
      jobDefinition.running++;

      // CALL THE ACTUAL METHOD TO PROCESS THE JOB!!!
      debug('[%s:%s] processing job', job.attrs.name, job.attrs._id);

      job.run()
        .catch(error => [error, job])
        .then(job => processJobResult(...Array.isArray(job) ? job : [null, job])); // eslint-disable-line promise/prefer-await-to-then

      // Re-run the loop to check for more jobs to process (locally)
      jobProcessing();
    } else {
      // Run the job immediately by putting it on the top of the queue
      debug('[%s:%s] concurrency preventing immediate run, pushing job to top of queue', job.attrs.name, job.attrs._id);
      enqueueJobs(job);
    }
  }
}
于 2020-08-03T09:01:36.737 回答