DioxusLabs/dioxus · error

template path stack capacity exceeded

Error message

template path stack capacity exceeded

What it means

TemplateLoweringCursor uses fixed-size stacks (TEMPLATE_PATH_STACK_CAP) for element frames and paths. Opening more nested elements than the stack capacity while lowering a template exhausts it, and this guard aborts with the capacity-exceeded message.

Source

Thrown at packages/core-template/src/storage.rs:170

impl TemplateLoweringCursor {
    pub const fn new() -> Self {
        let mut next_paths = [TemplatePath::empty(); TEMPLATE_PATH_STACK_CAP];
        next_paths[0] = TemplatePath::root(0);
        Self {
            enter_stack: [TemplateElementFrame {
                enter_index: 0,
                namespace: false,
                path: TemplatePath::empty(),
            }; TEMPLATE_PATH_STACK_CAP],
            next_paths,
            last_static_paths: [TemplatePath::empty(); TEMPLATE_PATH_STACK_CAP],
            stack_pointer: 0,
        }
    }

    pub const fn open_element(&mut self, enter_index: usize, namespace: bool) {
        if self.stack_pointer + 1 >= TEMPLATE_PATH_STACK_CAP {
            panic!("template path stack capacity exceeded");
        }
        let path = self.next_paths[self.stack_pointer];
        self.next_paths[self.stack_pointer] = path.next_sibling();
        self.enter_stack[self.stack_pointer] = TemplateElementFrame {
            enter_index,
            namespace,
            path,
        };
        self.next_paths[self.stack_pointer + 1] = path.next_child();
        self.last_static_paths[self.stack_pointer + 1] = TemplatePath::empty();
        self.last_static_paths[self.stack_pointer] = path;
        self.stack_pointer += 1;
    }

    pub const fn close_element(&mut self) -> TemplateElementFrame {
        if self.stack_pointer == 0 {
            panic!("template close op without matching open op");
        }

View on GitHub (pinned to 24f6a829df)

Solutions

  1. The template path stack overflowed its capacity. Reduce template nesting depth by splitting the component.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/core-template/src/storage.rs:170 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of DioxusLabs/dioxus@24f6a829df (2026-08-23). Data as JSON: /api/errors/db91fc37325382d0. Report an issue: GitHub.