{"record":{"id":"693643a22117b822","repo":"nodejs/node","slug":"und-err-invalid-arg-693643","errorCode":"UND_ERR_INVALID_ARG","errorMessage":"waitInMs must be a valid integer > 0","messagePattern":"waitInMs must be a valid integer > 0","errorType":"validation","errorClass":"InvalidArgumentError","httpStatus":null,"severity":"error","filePath":"deps/undici/src/lib/mock/mock-interceptor.js","lineNumber":34,"sourceCode":"  types: {\n    isPromise\n  }\n} = require('node:util')\n\n/**\n * Defines the scope API for an interceptor reply\n */\nclass MockScope {\n  constructor (mockDispatch) {\n    this[kMockDispatch] = mockDispatch\n  }\n\n  /**\n   * Delay a reply by a set amount in ms.\n   */\n  delay (waitInMs) {\n    if (typeof waitInMs !== 'number' || !Number.isInteger(waitInMs) || waitInMs <= 0) {\n      throw new InvalidArgumentError('waitInMs must be a valid integer > 0')\n    }\n\n    this[kMockDispatch].delay = waitInMs\n    return this\n  }\n\n  /**\n   * For a defined reply, never mark as consumed.\n   */\n  persist () {\n    this[kMockDispatch].persist = true\n    return this\n  }\n\n  /**\n   * Allow one to define a reply for a set amount of matching requests.\n   */\n  times (repeatTimes) {","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/undici/src/lib/mock/mock-interceptor.js#L16-L52","documentation":"Thrown by MockScope.delay when waitInMs is not a number, not an integer, or not greater than zero. delay sets a response latency on a mock dispatch; fractional, zero, or negative durations are rejected so the delay timer is always well-defined.","triggerScenarios":"Calling interceptor.reply(200).delay(0), delay(-100), delay(1.5), delay('500'), or delay(undefined). Also delay() with no argument (undefined).","commonSituations":"Passing a delay from a config file as a string, using 0 intending 'no delay' (use omit instead), or computing a delay that can go non-positive.","solutions":["Pass a positive integer of milliseconds: delay(500).","Omit delay() entirely when no delay is desired.","Coerce and clamp config values: delay(Math.max(1, Math.floor(config.delay)))."],"exampleFix":"// before\nintercept.reply(200).delay(config.timeout)\nintercept.reply(200).delay(0)\n\n// after\nintercept.reply(200).delay(Math.max(1, Number(config.timeout)))\nintercept.reply(200) // no delay needed","handlingStrategy":"validation","validationCode":"function safeDelay(scope, ms) {\n  if (typeof ms !== 'number' || !Number.isInteger(ms) || ms <= 0) {\n    throw new TypeError('delay expects a positive integer ms');\n  }\n  return scope.delay(ms);\n}","typeGuard":"function isPositiveIntegerMs(v) {\n  return typeof v === 'number' && Number.isInteger(v) && v > 0;\n}","tryCatchPattern":null,"preventionTips":["Omit delay() entirely when no delay is needed.","Coerce config strings with Number() and clamp with Math.max(1, ...).","Never pass 0 — omit the call instead."],"tags":["undici","mock","validation","timing","interceptor"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}