Skip to content

fix(sphinxdocs): clean stale worker output dir and doctrees on first request#3933

Merged
rickeylev merged 1 commit into
bazel-contrib:mainfrom
MartinNeudecker:main
Jul 17, 2026
Merged

fix(sphinxdocs): clean stale worker output dir and doctrees on first request#3933
rickeylev merged 1 commit into
bazel-contrib:mainfrom
MartinNeudecker:main

Conversation

@MartinNeudecker

@MartinNeudecker MartinNeudecker commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

The Sphinx worker keeps doctrees outside declared outputs so that incremental
builds survive across invocations. A newly started worker has no digest history,
so it treats every input as changed and re-reads all docs. Re-reading against
the stale environment left by a previous worker can produce spurious warnings,
e.g. duplicate labels, which become build failures when --fail-on-warning
is enabled.

On the first request, delete the worker output directory and doctree directory
so the worker starts from a clean Sphinx environment.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@rickeylev

Copy link
Copy Markdown
Collaborator

Ah, I think I understand now. I was confused because bazel clears output directories, but the doctree dir isn't the output directory. It's --doctree-dir={output_dir}_doctrees (sibling of the directory). Hence its state is undefined in between worker starts or invocations.

(ideally there'd be a way to restore the state, but i think clearing things after a restart makes sense. It already does that in another case if exit code 2 comes back from sphinx)

@rickeylev rickeylev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the fix!

@rickeylev
rickeylev added this pull request to the merge queue Jul 17, 2026
Merged via the queue into bazel-contrib:main with commit 8c5d11a Jul 17, 2026
6 checks passed
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