Skip to content

Svelte + TypeScript: fail loudly on companion TS timeouts; deterministic test fixture#1648

Open
xormania wants to merge 1 commit into
oraios:mainfrom
xormania:fix/svelte-ci-flake
Open

Svelte + TypeScript: fail loudly on companion TS timeouts; deterministic test fixture#1648
xormania wants to merge 1 commit into
oraios:mainfrom
xormania:fix/svelte-ci-flake

Conversation

@xormania

@xormania xormania commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Make the Svelte companion TypeScript server raise on readiness and indexing timeouts instead of silently proceeding with a partial index. This turns flaky/wrong cross-file results into clear failures.

Changes

  • TypeScriptLanguageServer: timeout handling factored into overridable hooks (_handle_server_ready_timeout, _handle_project_indexing_timeout); the base server keeps its historical permissive behavior, so plain TypeScript setups are unchanged.
  • SvelteTypeScriptServer (the companion owned by SvelteLanguageServer): overrides the hooks to raise TimeoutError with a diagnostic indexing-state summary (describe_indexing_state()) instead of serving requests from a cold or partially indexed program.
  • Configurable server_ready_timeout / indexing_timeout via ls_specific_settings.
  • SvelteCompanionPreparationError (raised when .svelte files cannot be opened on the companion) reports a count-first file listing capped at 10 entries and chains the first underlying error, so the cause is visible without DEBUG logging.
  • Svelte test fixture: npm ci with a committed package-lock.json, removing dependency-resolution non-determinism from CI runs.
  • Test fixture bootstrap: run svelte-kit sync explicitly and fail loudly if .svelte-kit/tsconfig.json cannot be generated. The fixture's prepare script masks sync failures (svelte-kit sync || echo ''), and a known npm bug ([BUG] Platform-specific optional dependencies not being included in package-lock.json when reinstalling with node_modules present npm/cli#4828) can silently skip platform-specific optional dependencies — the result is unresolvable $lib path aliases and cross-file tests failing with confusing partial results instead of a clear, actionable error.
  • codespell config: skip third-party fixture repositories (anchored pattern ./test/resources/repos; codespell matches skip globs against the ./-prefixed paths it walks, so an anchor-less pattern never matches).
  • Regression tests (test/solidlsp/test_typescript_timeout_policy.py): pin the timeout-policy split directly — base server permissive, Svelte companion strict — plus the settings plumbing (including svelte-over-typescript precedence for indexing_timeout) and wait_for_indexing_after_open semantics. No language-server processes are spawned; the tests are fully deterministic.
  • Docs: server_ready_timeout / indexing_timeout rows in the TypeScript and Svelte settings tables in docs/02-usage/050_configuration.md, including the companion's settings inheritance and strict behavior.

Known CI status

Checklist

  • This PR follows the guidelines in CONTRIBUTING.md regarding the scope of PRs.
  • For changes that add features or fix problems, I have added an entry to CHANGELOG.md, which concisely describes the change.

@xormania

xormania commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

I looked into how you do things. I'll update PRs. BTW - I like what you're doing, you've answered some useful context issues. I get it now.

@xormania xormania changed the title Svelte + TypeScript: fail loudly on companion TS timeouts; determinis… Svelte + TypeScript: fail loudly on companion TS timeouts; deterministic npm ci Jul 5, 2026
@xormania xormania force-pushed the fix/svelte-ci-flake branch from aeab868 to 46e9e2f Compare July 5, 2026 09:44
@xormania xormania changed the title Svelte + TypeScript: fail loudly on companion TS timeouts; deterministic npm ci Svelte + TypeScript: fail loudly on companion TS timeouts; deterministic test fixture Jul 5, 2026
@xormania xormania force-pushed the fix/svelte-ci-flake branch 3 times, most recently from 1bd4216 to c7e9e93 Compare July 5, 2026 10:50
@xormania

xormania commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

Ready

@xormania xormania marked this pull request as draft July 9, 2026 14:06
…tic test fixture

Make the Svelte companion TypeScript server raise on readiness and
indexing timeouts instead of silently proceeding with a partial index,
turning flaky/wrong cross-file results into clear failures:

- TypeScriptLanguageServer: timeout handling factored into overridable
  hooks (_handle_server_ready_timeout, _handle_project_indexing_timeout);
  the base server keeps its historical permissive behavior, so plain
  TypeScript setups are unchanged.
- SvelteTypeScriptServer: overrides the hooks to raise TimeoutError with
  a diagnostic indexing-state summary (describe_indexing_state()) instead
  of serving requests from a cold or partially indexed program.
- Configurable server_ready_timeout / indexing_timeout via
  ls_specific_settings.
- SvelteLanguageServer: file-open failures during companion preparation
  raise SvelteCompanionPreparationError with a count-first file listing
  (capped at 10), chained to the first underlying error so the cause is
  visible without DEBUG logging.

Apply the same fail-loudly principle to the test fixture bootstrap:

- Svelte test repo: npm ci with a committed package-lock.json, removing
  dependency-resolution non-determinism from CI runs.
- Run svelte-kit sync explicitly during fixture setup and fail loudly if
  .svelte-kit/tsconfig.json cannot be generated. The fixture's "prepare"
  script masks sync failures ("svelte-kit sync || echo ''"), and a known
  npm bug (npm/cli#4828) can silently skip platform-specific optional
  dependencies; the result is unresolvable $lib path aliases and
  cross-file tests failing with partial results instead of a clear,
  actionable error.
- codespell: skip third-party fixture repositories, using the anchored
  pattern ./test/resources/repos (codespell matches skip globs against
  the ./-prefixed paths it walks, so an anchor-less pattern never
  matches).

Also add direct regression tests for the timeout-policy split
(test/solidlsp/test_typescript_timeout_policy.py: base stays
permissive, companion raises, settings plumbing and precedence,
wait_for_indexing_after_open semantics; no LS processes, fully
deterministic), and document the server_ready_timeout /
indexing_timeout settings in the TypeScript and Svelte sections of
the configuration docs.
@xormania xormania force-pushed the fix/svelte-ci-flake branch from c7e9e93 to 2bd0a96 Compare July 9, 2026 23:53
xormania added a commit to xormania/serena that referenced this pull request Jul 9, 2026
Drop the SvelteKit demo-template baggage that no test exercises:
@fontsource/fira-mono, @neoconfetti/svelte, @tailwindcss/vite and
tailwindcss, along with their only usages (the layout.css imports, the
sverdle page's confetti effect, and the tailwind vite plugin).

A regenerated lockfile shrinks from 119 to 91 package entries (-24%).
rolldown and lightningcss remain: they are vite's own dependencies, not
tailwind's. Test-relevant files are untouched: tests reference the
sverdle page only as an expected member of reference/rename result
sets, and its $lib imports (game.ts, Words.svelte) are preserved.

Verified: clean npm install + svelte-kit sync + full svelte suite
(16/16) against the trimmed fixture.

Note: oraios#1648 commits a package-lock.json generated from the previous
dependency set; whichever change lands second must regenerate it.
@xormania xormania marked this pull request as ready for review July 10, 2026 03:36

@MischaPanch MischaPanch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, rather minor comments

"""
return self._indexing_complete.wait(timeout=timeout)

def wait_for_indexing_after_open(self, timeout: float, start_grace: float | None = None) -> bool:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this has nothing to do with opening files and it is in fact called at most once, in preparation for the reference search. The logic was previously inlined there, and I think it should still be inlined. Any reason you pulled this out as method? For sure it shouldn't be a public method

pytestmark = pytest.mark.svelte


def _sorted_reference_paths(refs: list[dict]) -> list[str]:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like there are several unrelated changes in this PR that clutter the diff and make review harder than necessary. Is this change really needed, for example?

@@ -0,0 +1,211 @@
"""Regression tests for the TypeScript/Svelte timeout policy split.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I propose to delete this, there's too much mocking for this to be useful or maintainable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants