Skip to content

[server] don't leave modules in unknown cache state when a check raises#12992

Open
kLabz wants to merge 1 commit into
developmentfrom
fix/server-check-module-state-leak
Open

[server] don't leave modules in unknown cache state when a check raises#12992
kLabz wants to merge 1 commit into
developmentfrom
fix/server-check-module-state-leak

Conversation

@kLabz

@kLabz kLabz commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

check_module sets m_cache_state to MSUnknown while checking a module and only resolves that state once the whole subgraph has been checked. If anything raises in between (e.g. a parse error while a CheckFileContentModification policy makes the check parse the file), modules stay MSUnknown with the m_checked of that compilation, which breaks the invariant asserted on the next check:

File "src/compiler/server/serverCache.ml", line 258, characters 12-19
Called from ServerCache.check_module.check.check_dependencies.(fun) ...

Modules cached by reference (import.hx modules, -D disable-hxb-cache) keep that state across requests, so the server keeps failing until it's restarted.

Register modules in unknown_state_modules before checking them and revert their state if the check raises.

check_module sets m_cache_state to MSUnknown while checking a module and only
resolves that state once the whole subgraph has been checked. If anything raises
in between (e.g. a parse error while a CheckFileContentModification policy makes
the check parse the file), modules stay MSUnknown with the m_checked of that
compilation, which breaks the invariant asserted on the next check:

  File "src/compiler/server/serverCache.ml", line 258, characters 12-19
  Called from ServerCache.check_module.check.check_dependencies.(fun) ...

Modules cached by reference (import.hx modules, -D disable-hxb-cache) keep that
state across requests, so the server keeps failing until it's restarted.

Register modules in unknown_state_modules before checking them and revert their
state if the check raises.
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.

1 participant