{"record":{"id":"917bcd1de843a044","repo":"nodejs/node","slug":"und-err","errorCode":"UND_ERR","errorMessage":"1 interceptor is pending:\\n\\n${pendingInterceptorsFormatter.format(pending)}","messagePattern":"1 interceptor is pending:\\\\n\\\\n(.+?)","errorType":"exception","errorClass":"UndiciError","httpStatus":null,"severity":"error","filePath":"deps/undici/src/lib/mock/mock-agent.js","lineNumber":224,"sourceCode":"    return this[kNetConnect]\n  }\n\n  pendingInterceptors () {\n    const mockAgentClients = this[kClients]\n\n    return Array.from(mockAgentClients.entries())\n      .flatMap(([origin, dispatcher]) => dispatcher[kDispatches].map(dispatch => ({ ...dispatch, origin })))\n      .filter(({ pending }) => pending)\n  }\n\n  assertNoPendingInterceptors ({ pendingInterceptorsFormatter = new PendingInterceptorsFormatter() } = {}) {\n    const pending = this.pendingInterceptors()\n\n    if (pending.length === 0) {\n      return\n    }\n\n    throw new UndiciError(\n      pending.length === 1\n        ? `1 interceptor is pending:\\n\\n${pendingInterceptorsFormatter.format(pending)}`.trim()\n        : `${pending.length} interceptors are pending:\\n\\n${pendingInterceptorsFormatter.format(pending)}`.trim()\n    )\n  }\n}\n\nmodule.exports = MockAgent\n","sourceCodeStart":206,"sourceCodeEnd":233,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/undici/src/lib/mock/mock-agent.js#L206-L233","documentation":"Thrown by `MockAgent.assertNoPendingInterceptors()` (an `UndiciError`, generic code `UND_ERR`) when exactly one mocked interceptor was registered but never matched/consumed by a real dispatch. In test suites this assertion verifies that every mocked route was actually exercised — a pending interceptor usually means a typo in the path/method, a wrong origin, or dead test setup. The message includes a formatted description of the unmatched interceptor.","triggerScenarios":"Registering `mockAgent.get(origin).intercept({ path: '/users', method: 'GET' }).reply(200)` but the code under test calls `/user` (typo), a different origin, or `POST`. After the test, `assertNoPendingInterceptors()` finds the one unmatched entry and throws. Singular form is chosen because `pending.length === 1`.","commonSituations":"Path/method typos between the intercept declaration and the code under test; origin mismatch (trailing slash, protocol, port); the code under test not being invoked (skipped branch, early throw); intercept declared on the wrong MockClient/MockPool; query-string differences when matching is strict.","solutions":["Compare the intercept's `path`/`method`/`origin` against the actual request your code makes — use `mockAgent.getCallHistory()` if call history is enabled.","Ensure the code under test actually runs and reaches the mocked dispatch (no early return, no swallowed error).","If the interceptor is intentionally unused, remove it or split it into its own test.","Check for trailing-slash and protocol/port mismatches; consider enabling `ignoreTrailingSlash` on the MockAgent."],"exampleFix":"// before\nmockAgent.get('https://api.test').intercept({ path: '/user', method: 'GET' }).reply(200)\nawait fetch('https://api.test/users') // typo: /user vs /users\nmockAgent.assertNoPendingInterceptors() // throws: 1 pending\n\n// after\nmockAgent.get('https://api.test').intercept({ path: '/users', method: 'GET' }).reply(200)\nawait fetch('https://api.test/users')\nmockAgent.assertNoPendingInterceptors() // passes","handlingStrategy":"validation","validationCode":"function assertAllInterceptorsConsumed(mockAgent) {\n  const pending = mockAgent.pendingInterceptors()\n  if (pending.length === 1) {\n    const p = pending[0]\n    throw new Error(`Unmatched intercept: ${p.method} ${p.origin}${p.path}`)\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  mockAgent.assertNoPendingInterceptors()\n} catch (err) {\n  // err lists the unmatched interceptor; reconcile path/method/origin\n  throw err\n}","preventionTips":["Reconcile intercept path/method/origin against the real request URL.","Enable call history to inspect what was actually dispatched.","Consider ignoreTrailingSlash to absorb trailing-slash mismatches."],"tags":["undici","mock","mock-agent","test-assertion","interceptor","pending"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}