{"record":{"id":"88b36da0eb25137e","repo":"garrytan/gstack","slug":"usage-browse-load-html-file-wait-until-load","errorCode":null,"errorMessage":"Usage: browse load-html <file> [--wait-until load|domcontentloaded|networkidle] [--tab-id <N>]  |  load-html --from-file <payload.json> [--tab-id <N>]","messagePattern":"Usage: browse load-html <file> \\[--wait-until load\\|domcontentloaded\\|networkidle\\] \\[--tab-id <N>\\]  \\|  load-html --from-file <payload\\.json> \\[--tab-id <N>\\]","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"browse/src/write-commands.ts","lineNumber":249,"sourceCode":"      // Inline HTML path: validate size + magic byte, then setContent directly.\n      if (fromFilePayload) {\n        const MAX_BYTES = parseInt(process.env.GSTACK_BROWSE_MAX_HTML_BYTES || '', 10) || (50 * 1024 * 1024);\n        if (Buffer.byteLength(fromFilePayload.html, 'utf8') > MAX_BYTES) {\n          throw new Error(\n            `load-html: --from-file html too large (> ${MAX_BYTES} bytes). ` +\n            'Raise with GSTACK_BROWSE_MAX_HTML_BYTES=<N>.'\n          );\n        }\n        const peek = fromFilePayload.html.trimStart();\n        if (!/^<[a-zA-Z!?]/.test(peek)) {\n          throw new Error('load-html: --from-file html does not start with a valid markup opener');\n        }\n        const finalWaitUntil = fromFilePayload.waitUntil ?? waitUntil;\n        await session.setTabContent(fromFilePayload.html, { waitUntil: finalWaitUntil });\n        return `Loaded HTML: (inline from --from-file, ${fromFilePayload.html.length} chars)`;\n      }\n\n      if (!filePath) throw new Error('Usage: browse load-html <file> [--wait-until load|domcontentloaded|networkidle] [--tab-id <N>]  |  load-html --from-file <payload.json> [--tab-id <N>]');\n\n      // Extension allowlist\n      const ALLOWED_EXT = ['.html', '.htm', '.xhtml', '.svg'];\n      const ext = path.extname(filePath).toLowerCase();\n      if (!ALLOWED_EXT.includes(ext)) {\n        throw new Error(\n          `load-html: file does not appear to be HTML. Expected .html/.htm/.xhtml/.svg, got ${ext || '(no extension)'}. Rename the file if it's really HTML.`\n        );\n      }\n\n      const absolutePath = path.resolve(filePath);\n\n      // Safe-dirs check (reuses canonical read-side policy)\n      try {\n        validateReadPath(absolutePath);\n      } catch (e: any) {\n        throw new Error(\n          `load-html: ${absolutePath} must be under ${SAFE_DIRECTORIES.join(' or ')} (security policy). Copy the file into the project tree or /tmp first.`","sourceCodeStart":231,"sourceCodeEnd":267,"githubUrl":"https://github.com/garrytan/gstack/blob/94993f74012782fd94416dd44b8314f6363a13a4/browse/src/write-commands.ts#L231-L267","documentation":"Error \"Usage: browse load-html <file> [--wait-until load|domcontentloaded|networkidle] [--tab-id <N>]  |  load-html --from-file <payload.json> [--tab-id <N>]\" thrown in garrytan/gstack.","triggerScenarios":"Thrown at browse/src/write-commands.ts:249 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"94993f74012782fd94416dd44b8314f6363a13a4","analyzedAt":"2026-08-12T04:06:23.140Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}