Svelte + TypeScript: fail loudly on companion TS timeouts; deterministic test fixture#1648
Svelte + TypeScript: fail loudly on companion TS timeouts; deterministic test fixture#1648xormania wants to merge 1 commit into
Conversation
|
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. |
aeab868 to
46e9e2f
Compare
1bd4216 to
c7e9e93
Compare
|
Ready |
…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.
c7e9e93 to
2bd0a96
Compare
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.
MischaPanch
left a comment
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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]: |
There was a problem hiding this comment.
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. | |||
There was a problem hiding this comment.
I propose to delete this, there's too much mocking for this to be useful or maintainable
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 bySvelteLanguageServer): overrides the hooks to raiseTimeoutErrorwith a diagnostic indexing-state summary (describe_indexing_state()) instead of serving requests from a cold or partially indexed program.server_ready_timeout/indexing_timeoutvials_specific_settings.SvelteCompanionPreparationError(raised when.sveltefiles 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.npm ciwith a committedpackage-lock.json, removing dependency-resolution non-determinism from CI runs.svelte-kit syncexplicitly and fail loudly if.svelte-kit/tsconfig.jsoncannot be generated. The fixture'spreparescript masks sync failures (svelte-kit sync || echo ''), and a known npm bug ([BUG] Platform-specific optional dependencies not being included inpackage-lock.jsonwhen reinstalling withnode_modulespresent npm/cli#4828) can silently skip platform-specific optional dependencies — the result is unresolvable$libpath aliases and cross-file tests failing with confusing partial results instead of a clear, actionable error../test/resources/repos; codespell matches skip globs against the./-prefixed paths it walks, so an anchor-less pattern never matches).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 forindexing_timeout) andwait_for_indexing_after_opensemantics. No language-server processes are spawned; the tests are fully deterministic.server_ready_timeout/indexing_timeoutrows in the TypeScript and Svelte settings tables indocs/02-usage/050_configuration.md, including the companion's settings inheritance and strict behavior.Known CI status
other-langs (macos-latest): will fail on the unrelated, pre-existing HLSL build break onmain(shader-sense 1.4.0 broke the from-source build of shader_language_server 1.3.1) until HLSL: build shader_language_server with cargo --locked to fix macOS CI #1652 lands. I will refresh this branch once that merges.Checklist
CONTRIBUTING.mdregarding the scope of PRs.CHANGELOG.md, which concisely describes the change.