{"record":{"id":"f02d1375e245935b","repo":"vitejs/vite","slug":"hmr-is-not-supported-by-this-runner-transport-but","errorCode":null,"errorMessage":"HMR is not supported by this runner transport, but `hmr` option was set to true","messagePattern":"HMR is not supported by this runner transport, but `hmr` option was set to true","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/vite/src/module-runner/runner.ts","lineNumber":74,"sourceCode":"    private debug?: ModuleRunnerDebugger | undefined,\n  ) {\n    this.evaluatedModules = options.evaluatedModules ?? new EvaluatedModules()\n    this.transport = normalizeModuleRunnerTransport(options.transport)\n    if (options.hmr !== false) {\n      const optionsHmr = options.hmr ?? true\n      const resolvedHmrLogger: HMRLogger =\n        optionsHmr === true || optionsHmr.logger === undefined\n          ? hmrLogger\n          : optionsHmr.logger === false\n            ? silentConsole\n            : optionsHmr.logger\n      this.hmrClient = new HMRClient(\n        resolvedHmrLogger,\n        this.transport,\n        ({ acceptedPath }) => this.import(acceptedPath),\n      )\n      if (!this.transport.connect) {\n        throw new Error(\n          'HMR is not supported by this runner transport, but `hmr` option was set to true',\n        )\n      }\n      this.transport.connect(createHMRHandlerForRunner(this))\n    } else {\n      this.transport.connect?.()\n    }\n    if (options.sourcemapInterceptor !== false) {\n      this.resetSourceMapSupport = enableSourceMapSupport(this)\n    }\n  }\n\n  /**\n   * URL to execute. Accepts file path, server path or id relative to the root.\n   */\n  public async import<T = any>(url: string): Promise<T> {\n    const fetchedModule = await this.cachedModule(url)\n    return await this.cachedRequest(url, fetchedModule)","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/vitejs/vite/blob/b4d66fee14d970f45b8a6f3d7d6aee73ca9b88ab/packages/vite/src/module-runner/runner.ts#L56-L92","documentation":"When constructing a ModuleRunner with `hmr` not false, the constructor checks that `transport.connect` exists - HMR requires a duplex transport that can receive push messages. If the transport only supports invoke (request/response) and has no `connect`, the constructor throws immediately because HMR cannot function.","triggerScenarios":"Constructing `new ModuleRunner({ transport: invokeOnlyTransport, hmr: true })` (or leaving `hmr` at its default `true`) where `transport.connect` is undefined. Common when reusing a fetch-only transport (e.g. a manual `fetchModule` wrapper) for SSR evaluation that does not implement HMR.","commonSituations":"Building a custom module-runner transport for SSR/testing that omits `connect`. Forgetting to disable HMR in a one-shot evaluation script.","solutions":["Set `hmr: false` in the ModuleRunner options if you do not need hot updates.","Implement `connect` on your transport (a method that registers a handler and returns a disposer) to enable HMR."],"exampleFix":"// before\nnew ModuleRunner({ transport: { invoke: fetchModule /* no connect */ } })\n// after\nnew ModuleRunner({ transport: { invoke: fetchModule }, hmr: false })","handlingStrategy":"validation","validationCode":"function validateRunnerTransportForHmr(transport: { connect?: unknown }, hmr: unknown) {\n  if (hmr !== false && typeof transport.connect !== 'function') {\n    throw new Error('Transport has no connect() - set hmr: false or implement connect')\n  }\n}","typeGuard":"function transportSupportsHmr(t: unknown): t is { connect: () => void; invoke: (...a: any[]) => any } {\n  return !!t && typeof (t as any).connect === 'function' && typeof (t as any).invoke === 'function'\n}","tryCatchPattern":null,"preventionTips":["If your transport is fetch-only (invoke only), always set hmr: false on the runner.","When implementing HMR, implement connect(handler): disposer on the transport."],"tags":["module-runner","hmr","transport","config-validation"],"backgroundTag":null,"analyzedSha":"b4d66fee14d970f45b8a6f3d7d6aee73ca9b88ab","analyzedAt":"2026-08-11T11:49:19.515Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}