{"record":{"id":"de3f53d34b6f67aa","repo":"vitejs/vite","slug":"invalid-hot-accept-usage","errorCode":null,"errorMessage":"invalid hot.accept() usage.","messagePattern":"invalid hot\\.accept\\(\\) usage\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/vite/src/shared/hmr.ts","lineNumber":74,"sourceCode":"    this.newListeners = new Map()\n    hmrClient.ctxToListenersMap.set(ownerPath, this.newListeners)\n  }\n\n  get data(): any {\n    return this.hmrClient.dataMap.get(this.ownerPath)\n  }\n\n  accept(deps?: any, callback?: any): void {\n    if (typeof deps === 'function' || !deps) {\n      // self-accept: hot.accept(() => {})\n      this.acceptDeps([this.ownerPath], ([mod]) => deps?.(mod))\n    } else if (typeof deps === 'string') {\n      // explicit deps\n      this.acceptDeps([deps], ([mod]) => callback?.(mod))\n    } else if (Array.isArray(deps)) {\n      this.acceptDeps(deps, callback)\n    } else {\n      throw new Error(`invalid hot.accept() usage.`)\n    }\n  }\n\n  // export names (first arg) are irrelevant on the client side, they're\n  // extracted in the server for propagation\n  acceptExports(\n    _: string | readonly string[],\n    callback?: (data: any) => void,\n  ): void {\n    this.acceptDeps([this.ownerPath], ([mod]) => callback?.(mod))\n  }\n\n  dispose(cb: (data: any) => void): void {\n    this.hmrClient.disposeMap.set(this.ownerPath, cb)\n  }\n\n  prune(cb: (data: any) => void): void {\n    this.hmrClient.pruneMap.set(this.ownerPath, cb)","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/vitejs/vite/blob/b4d66fee14d970f45b8a6f3d7d6aee73ca9b88ab/packages/vite/src/shared/hmr.ts#L56-L92","documentation":"Thrown by the HMR context's accept() when the deps argument is neither undefined/null, nor a function (self-accept), nor a string, nor an array. accept only supports those four shapes; anything else (an object, number, boolean) is a misuse of the HMR API.","triggerScenarios":"Calling import.meta.hot.accept(deps) where deps is an object, number, or other invalid type. The final else branch at hmr.ts:74 fires after the function/string/array checks fail.","commonSituations":"Passing an object map of dependencies by mistake. Spreading into accept with a bad shape. Mis-typed HMR API surface in a framework wrapper around import.meta.hot. Generated HMR code from a misbehaving plugin.","solutions":["Use one of the supported forms: hot.accept(), hot.accept(cb), hot.accept('./dep', cb), or hot.accept(['./a','./b'], cb).","If accepting multiple deps, pass an array of strings, not an object.","Check that any framework/plugin generating hot.accept() calls emits a valid argument shape."],"exampleFix":"// before\nimport.meta.hot.accept({ './a': cb }) // throws\n// after\nimport.meta.hot.accept(['./a'], cb)","handlingStrategy":"validation","validationCode":"function isValidAcceptDeps(deps: unknown): boolean {\n  return deps == null || typeof deps === 'function' || typeof deps === 'string' || Array.isArray(deps)\n}","typeGuard":"function isValidAcceptArg(deps: unknown): boolean {\n  return deps == null || typeof deps === 'function' || typeof deps === 'string' || Array.isArray(deps)\n}","tryCatchPattern":null,"preventionTips":["Use only the documented accept() shapes: none, callback, single string, or array of strings.","If a plugin generates HMR accept calls, validate the deps shape before emitting."],"tags":["hmr","client","api-misuse"],"backgroundTag":null,"analyzedSha":"b4d66fee14d970f45b8a6f3d7d6aee73ca9b88ab","analyzedAt":"2026-08-11T11:49:19.515Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}