Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion deploy/docker/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,8 +482,12 @@ def _config_from_json(data: dict) -> dict:
app.include_router(init_job_router(redis, config, token_dep))

# ── monitor router ──────────────────────────────────────────
# Do not attach token_dep at router level: it is HTTP Request-only and breaks
# the WebSocket upgrade on /monitor/ws (TypeError: _principal() missing 'request').
# AuthGateMiddleware already authenticates HTTP + WS; destructive monitor
# actions keep their own Depends(require_admin).
from monitor_routes import router as monitor_router
app.include_router(monitor_router, dependencies=[Depends(token_dep)])
app.include_router(monitor_router)

logger = logging.getLogger(__name__)

Expand Down
16 changes: 11 additions & 5 deletions deploy/docker/static/playground/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -563,10 +563,13 @@ <h2 class="font-medium text-accent">🔥 Stress Test</h2>
const code = cm.getValue().trim();
if (!code) return {};

// Server requires `type` alongside `code` (CrawlerRunConfig | BrowserConfig).
// The UI already tracks this in #cfg-type; omitting it always 400s Advanced Config.
const cfgType = document.getElementById('cfg-type').value;
const res = await authFetch('/config/dump', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ code }),
body: JSON.stringify({ type: cfgType, code }),
});

const statusEl = document.getElementById('cfg-status');
Expand Down Expand Up @@ -652,9 +655,12 @@ <h2 class="font-medium text-accent">🔥 Stress Test</h2>
// Detect if stream is requested inside payload
function shouldUseStream(payload) {
const toBool = (v) => v === true || (typeof v === 'string' && v.toLowerCase() === 'true');
const fromCrawler = payload && payload.crawler_config && payload.crawler_config.params && payload.crawler_config.params.stream;
// Successful /config/dump returns { type, params: { stream, ... } }
const fromCrawlerParams = payload && payload.crawler_config && payload.crawler_config.params && payload.crawler_config.params.stream;
// Fallback / minimal shapes may set stream at the crawler_config top level
const fromCrawlerTop = payload && payload.crawler_config && payload.crawler_config.stream;
const direct = payload && payload.stream;
return toBool(fromCrawler) || toBool(direct);
return toBool(fromCrawlerParams) || toBool(fromCrawlerTop) || toBool(direct);
}

// Main run function
Expand All @@ -676,8 +682,8 @@ <h2 class="font-medium text-accent">🔥 Stress Test</h2>
const streamFlag = /stream\s*=\s*True/i.test(codeText);
const isCrawlEndpoint = document.getElementById('endpoint').value === 'crawl';
if (isCrawlEndpoint && streamFlag) {
// Fallback: proceed with minimal config only for stream
advConfig = { crawler_config: { stream: true } };
// Fallback: minimal dump-shaped config so shouldUseStream + server load agree
advConfig = { crawler_config: { type: 'CrawlerRunConfig', params: { stream: true } } };
} else {
updateStatus('error');
document.querySelector('#response-content code').textContent =
Expand Down