mirror of
https://github.com/tiennm99/serena.git
synced 2026-10-04 20:13:29 +00:00
The Nomic solidity-language-server validates asynchronously: document
changes are debounced (~250ms), validation runs a forge/solc compile,
and completion is signalled with the custom notification
custom/validation-job-status -- emitted on every completion path
(success, validation failure, job errors; verified in the bundled 0.8.4
package, which publishes the document's diagnostics before the signal).
Serena ignored the signal ("Unhandled method
'custom/validation-job-status'") and waited a fixed 2.5s for a
non-empty publishDiagnostics, returning [] whenever validation finished
later. Warm environments fit the window; slow or cold ones (macOS and
Windows CI runners, which download solc 0.8.20 on every run -- the CI
cache only covers ~/.serena/language_servers/static, not
~/.local/share/svm) often do not. This is the root cause of the
empty-diagnostics failures of test_file_diagnostics[solidity]: xfailed
on macOS since its introduction (bd7e64e8) and failing on Windows on
Tests run #4236, job catch-all (windows-latest). Shrinking the wait
reproduces the exact failure signature (AssertionError: []) on Linux.
Changes:
- Handle custom/validation-job-status (threading.Event + last payload).
The payload carries no document URI, so the event is global to the
server instance.
- request_text_document_diagnostics keeps the 2.5s non-empty publish
wait as the fast path. When it misses, it awaits the completion
signal against a 60s deadline (aligned with the indexing wait) and
takes the generation-advancing publication for the request URI,
accepting an empty result as the validated answer; a completion that
brings no publication for the URI (e.g. one belonging to another
document) re-arms the wait until the deadline. If the signal never
arrives, a warning is logged and the previous empty-result behavior
applies, bounded by the deadline.
- Remove the darwin xfail from test_file_diagnostics; add regression
tests for the fallback delivery (fast path forced to miss), for the
never-signalled bound, and for re-arming on a spurious completion
belonging to another document.
- CHANGELOG entry under Language Servers.
Design notes:
- Mirrors #1639 (TypeScript/VTS: event-based indexing wait replacing a
fixed sleep).
- The simpler alternative -- accepting empty publications and raising
the fixed wait -- was rejected: without the completion signal, an
early clear-on-open publication would be taken as the answer, and
every clean file would stall for the full wait.
- Supersedes the quarantine approach of draft PR #1674 (broadening the
xfail to non-Linux); whichever lands second resolves the trivial
conflict on the xfail block.