Fix max recursion depth error during Sphinx hot reload#28
Draft
Fix max recursion depth error during Sphinx hot reload#28
Conversation
- Modified get_safe_config to track visited objects in current traversal path - Use try-finally to remove objects from visited set after processing - This prevents infinite recursion while allowing same object from different paths - Fixes max depth recursion error during sphinx hot reload Co-authored-by: ubmarco <839934+ubmarco@users.noreply.github.com>
Co-authored-by: ubmarco <839934+ubmarco@users.noreply.github.com>
- Remove redundant isinstance check for str/bytes (already excluded by dict/list/tuple/set check) - Store obj_id in visited_obj_id variable for use in finally blocks - Use stored visited_obj_id instead of recalculating id(obj) in finally blocks Co-authored-by: ubmarco <839934+ubmarco@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix max depth reached error when hot reloading via sphinx
Fix max recursion depth error during Sphinx hot reload
Feb 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
During Sphinx hot reloads (e.g., with esbonio), configuration objects can contain circular references, causing
get_safe_configto infinitely recurse when serializing to TOML.Changes
visited: set[int]parameter toget_safe_configto detect circular referencesvisitedafter processing, allowing the same object to be referenced from different paths (A→C, B→C) while preventing true cycles (A→B→C→A)Test Coverage
Added
test_no_recursion_error_on_rebuildto verify rebuild scenarios don't cause recursion errors.Original prompt
This section details on the original issue you should resolve
<issue_title>[BUG] Max depth reached error when hot reloading via sphinx (e.g. with esbonio)</issue_title>
<issue_description>There currently seems to be a bug where sphinx errors due to this extension as it reaches the max depth recursion.
Error:
This continues until:
Steps to reproduce:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.