saadeghi/daisyui · error · Error

--timeout must be a positive number of milliseconds

Error message

--timeout must be a positive number of milliseconds

What it means

Thrown while parsing --timeout in pr-preview.mjs when the supplied string is not a finite positive number (Number(value) is NaN/Infinity or <= 0). The value must be a positive integer number of milliseconds.

Source

Thrown at packages/tailwind-play-share/pr-preview.mjs:70

        options.baseSha = takeValue(argv, index, argument)
        index += 1
        break
      case "--head-sha":
        options.headSha = takeValue(argv, index, argument)
        index += 1
        break
      case "--output":
        options.output = takeValue(argv, index, argument)
        index += 1
        break
      case "--browser":
        options.browser = takeValue(argv, index, argument)
        index += 1
        break
      case "--timeout": {
        const timeoutMs = Number(takeValue(argv, index, argument))
        if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {
          throw new Error("--timeout must be a positive number of milliseconds")
        }
        options.timeoutMs = timeoutMs
        index += 1
        break
      }
      case "--verbose":
        options.verbose = true
        break
      case "--help":
      case "-h":
        options.help = true
        break
      default:
        throw new Error(`Unknown option: ${argument}`)
    }
  }

  return options

View on GitHub (pinned to 42b09e637e)

Solutions

  1. Pass a plain positive integer of milliseconds, e.g. --timeout 60000.
  2. Drop any unit suffix; the flag is milliseconds only.
  3. Omit the flag to accept the 45000ms default.

Example fix

// before
--timeout 45s

// after
--timeout 45000
Defensive patterns

Strategy: validation

Validate before calling

function parseTimeoutMs(raw) {
  const ms = Number(raw)
  if (!Number.isFinite(ms) || ms <= 0) {
    throw new Error(`--timeout must be a positive integer of milliseconds, got: ${raw}`)
  }
  return ms
}

Type guard

const isPositiveMillis = (v) => Number.isFinite(Number(v)) && Number(v) > 0

Try / catch

try {
  options = parsePreviewArgs(argv)
} catch (error) {
  if (error.message.includes("--timeout must be a positive number")) {
  // re-prompt/fix the timeout value
  }
  throw error
}

Prevention

When it happens

Trigger: takeValue returns a string like "abc", "", "-5", "0", or "Infinity"; Number() then yields a non-finite or non-positive result and the guard fires.

Common situations: Typing the unit ("--timeout 45s"), passing zero/negative, an empty interpolation, or a locale-specific decimal separator.

Understand the failure class

Related errors


AI-assisted analysis of saadeghi/daisyui@42b09e637e (2026-08-13). Data as JSON: /api/errors/9c5c9716f5d06f3b. Report an issue: GitHub.