Search code examples
javascriptnode.jschild-processspawn

Is there any way to set timeout at child_process spawn?


is there any way to set timeout option at child_process spawn?

Here is my code. But I think it doesn't work.... When I remove this : , { timeout: 100 * 60 } , it works.

const { spawn } = require('child_process')

function spawnPython() {
  const job2 = new CronJob({
    cronTime: '36 17 * * *',
    onTick() {
      const smartstoreReview = spawn(
        'python3', ['smartstore_review.py'], { timeout: 100 * 60 }
      )
.
.
.

Solution

  • Simple problem from comments:

    They expected timeout to set "run in 6 seconds", not "run for 6 seconds" (that's timeout)