fix: view page polls readiness before loading iframe
Session view page was loading the iframe immediately on load, causing Bad Gateway if the container was still starting. Now polls /status until ready, then sets iframe src.
This commit is contained in:
+21
-2
@@ -1665,12 +1665,31 @@ def session_view_page(session_id: str, request: Request, user: User = Depends(re
|
|||||||
.cr-val{{font:600 13px/1 monospace;color:#dce8f5;flex:1;overflow:hidden;
|
.cr-val{{font:600 13px/1 monospace;color:#dce8f5;flex:1;overflow:hidden;
|
||||||
text-overflow:ellipsis;white-space:nowrap;}}
|
text-overflow:ellipsis;white-space:nowrap;}}
|
||||||
.cr-masked{{letter-spacing:.1em;font-size:14px;}}
|
.cr-masked{{letter-spacing:.1em;font-size:14px;}}
|
||||||
|
|
||||||
.cr-hint{{margin:4px 0 0;font:400 11px/1.35 sans-serif;color:rgba(180,210,240,.65);}}
|
.cr-hint{{margin:4px 0 0;font:400 11px/1.35 sans-serif;color:rgba(180,210,240,.65);}}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<iframe src="{iframe_src}" allow="clipboard-read; clipboard-write"></iframe>{creds_html}
|
<iframe id="app-frame" src="" allow="clipboard-read; clipboard-write" style="display:none"></iframe>{creds_html}
|
||||||
|
<script>
|
||||||
|
const sessionId = "{session_id}";
|
||||||
|
const iframeSrc = "{iframe_src}";
|
||||||
|
async function waitReady() {{
|
||||||
|
try {{
|
||||||
|
const r = await fetch(`/api/sessions/${{sessionId}}/status`, {{credentials:'include'}});
|
||||||
|
if (r.ok) {{
|
||||||
|
const data = await r.json();
|
||||||
|
if (data.ready) {{
|
||||||
|
const f = document.getElementById('app-frame');
|
||||||
|
f.src = iframeSrc;
|
||||||
|
f.style.display = '';
|
||||||
|
return;
|
||||||
|
}}
|
||||||
|
}}
|
||||||
|
}} catch(e) {{}}
|
||||||
|
setTimeout(waitReady, 400);
|
||||||
|
}}
|
||||||
|
waitReady();
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
""".strip()
|
""".strip()
|
||||||
|
|||||||
Reference in New Issue
Block a user