lablup / lablup/backend.ai-webui

Dev server boot blocks ~2.8s rebuilding the search index, which its own comment says must never block

Closed
#9,642 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
133
Forks
81
Avg merge
1d 12h
Merged PRs (30d)
355

Description

## Problem

`scripts/dev.mjs` rebuilds the global search palette index on every `pnpm run dev`, with `spawnSync` — so it blocks the boot. The comment right above it states the opposite intent:

```
// Refresh the global search palette's index once (~0.7 s). It is committed, so
// a stale one only means stale search results — never block the dev server.
const searchIndex = spawnSync(...)
```

Two things are wrong: `spawnSync` blocks by definition, and the `~0.7 s` estimate is stale.

## Measurements (this box, 8 cores)

A timestamped `pnpm run dev` reaches Vite `ready` in **8.45s**, of which **6.8s is spent before Vite starts**:

| Phase | Time |
|---|---|

|—|—|
|---|---|

| pnpm script startup | 1.67s |
|---|---|

| portless proxy check | 0.14s |
|---|---|

| **search index build** | **3.09s** |
|---|---|

| `gh pr view` | 0.59s |
|---|---|

| concurrently to pnpm spawn chain | 1.68s |
|---|---|

| Vite ready (warm dep cache) | 1.22s |
|---|---|

Standalone, the index build measures **2.8s** across three runs (user 3.0s, single-threaded CPU-bound — not contention from the other dev servers on the box). It walks the transitive import graph from `routes.tsx` with `MAX_DEPTH = Infinity`, so the cost grows with the codebase.

There is no cache — no mtime or hash gate — so an unchanged tree re-parses in full on every boot.

## Why it is safe to fix

The artifact is committed (ADR 0003) and staleness is already gated by `scripts/verify.sh` and `.github/workflows/typecheck.yml`. A stale index during a dev session only means stale palette results.

## Proposal

Make the step non-blocking, or gate it on the mtimes of its inputs (`routes.tsx`, `en.json`, the extractor) against the committed artifact. Either brings boot to roughly 5.5s.

Introduced by FR-3558 (#8811).

JIRA Issue: FR-3925

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in scripts/dev.mjs at the search-index rebuild using spawnSync, then run pnpm run dev to reproduce the boot delay and inspect the committed artifact referenced by ADR 0003. Check scripts/verify.sh and .github/workflows/typecheck.yml to understand the existing staleness checks. Done means the index step no longer blocks dev-server startup while the existing verification remains valid.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, vite
Domain
build-system, devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.