{"record":{"id":"93f71d6266a283db","repo":"leptos-rs/leptos","slug":"hot-reloading-error","errorCode":null,"errorMessage":"[HOT RELOADING] Error: ","messagePattern":"\\[HOT RELOADING\\] Error: ","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"leptos_hot_reload/src/patch.js","lineNumber":224,"sourceCode":"              const parent =\n                node.nodeType === Node.COMMENT_NODE ? node.parentNode : node;\n              if (!after) {\n                parent.appendChild(newChild);\n              } else {\n                parent.insertBefore(\n                  newChild,\n                  (after.node || after.start).nextSibling,\n                );\n              }\n            }\n          } else {\n            console.warn(\"[HOT RELOADING] Unmatched action\", action);\n          }\n        }\n      }\n    }\n  } catch (e) {\n    console.warn(\"[HOT RELOADING] Error: \", e);\n  }\n\n  function fromReplacementNode(node, actualChildren) {\n    if (node.Html) {\n      return fromHTML(node.Html);\n    } else if (node.Fragment) {\n      const frag = document.createDocumentFragment();\n      for (const child of node.Fragment) {\n        frag.appendChild(fromReplacementNode(child, actualChildren));\n      }\n      return frag;\n    } else if (node.Element) {\n      const element = document.createElement(node.Element.name);\n      for (const [name, value] of node.Element.attrs) {\n        element.setAttribute(name, value);\n      }\n      for (const child of node.Element.children) {\n        element.appendChild(fromReplacementNode(child, actualChildren));","sourceCodeStart":206,"sourceCodeEnd":242,"githubUrl":"https://github.com/leptos-rs/leptos/blob/32d20f6c9d517451d77beb68d88c7716823dac41/leptos_hot_reload/src/patch.js#L206-L242","documentation":"The outer try/catch of patch(json) caught any exception thrown while applying a hot-reload patch batch (JSON parse failure, null dereference on child.node, missing DOM nodes, etc.) and logs it as a warning. The whole patch batch for that view is aborted mid-way, leaving the DOM partially patched until a full reload.","triggerScenarios":"Any runtime error inside patch(): invalid JSON string passed to patch, childAtPath returning undefined then accessed (.node/.children), action handlers assuming fields exist, Range operations on detached nodes.","commonSituations":"Server sends malformed or truncated JSON over the dev websocket; DOM was mutated externally so expected nodes are gone; race where patches arrive before markers exist in the document.","solutions":["Read the logged error object `e` in the console to find the actual failing operation.","Hard-reload the page; partial patches cannot be rolled back automatically.","Validate the incoming JSON payload (log it — patch already prints '[HOT RELOAD]' with the parsed views).","Guard handlers against undefined children before dereferencing `.node` (see ReplaceWith/RemoveChild paths)."],"exampleFix":"// before (fragile)\nconst toRemove = child.children[action.RemoveChild.at];\nlet toRemoveNode = toRemove.node;\n// after\nconst toRemove = child.children && child.children[action.RemoveChild.at];\nif (!toRemove) { console.warn(\"missing child\", action); return; }\nlet toRemoveNode = toRemove.node;","handlingStrategy":"try-catch","validationCode":"// Validate payload before calling patch:\ntry { JSON.parse(json); } catch (e) { console.warn('bad hot-reload payload', e); return; }","typeGuard":null,"tryCatchPattern":"try {\n  patch(json);\n} catch (e) {\n  console.warn('[HOT RELOADING] Error: ', e);\n  location.reload(); // partial patch state is unrecoverable\n}","preventionTips":["Reload the page on any '[HOT RELOADING] Error:' — the DOM may be half-patched.","Avoid editing DOM in devtools while hot reload is connected.","Check websocket payload integrity if errors appear on every reload."],"tags":["hot-reload","javascript","uncaught-exception"],"backgroundTag":"hot-reload-patch-crash","analyzedSha":"32d20f6c9d517451d77beb68d88c7716823dac41","analyzedAt":"2026-09-01T18:55:42.580Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T01:17:15.007Z"}