I’d like to suggest adding a maximum nesting depth for the built-in [details] feature, or introducing a site setting that allows administrators to configure this limit.
The problem
Recently, a user on my Discourse forum created a post containing 24 levels of nested [details] sections.
This caused several problems:
- Browser performance: Users reported that expanding multiple levels caused Firefox to become extremely slow or unresponsive.
- Markdown endpoint timeouts: Accessing the topic’s
.mdendpoint became extremely slow. We observed requests taking 19.8 seconds and 31.1 seconds. - Server errors: The Markdown endpoint sometimes returned an “Oops” error page. The Discourse logs also showed Pitchfork worker timeout warnings during Markdown conversion.
- Potential resource exhaustion: Since search engines and AI crawlers frequently request
.mdendpoints, a deeply nested post could repeatedly trigger expensive processing and consume server resources.
After removing the problematic post, the Markdown endpoint returned HTTP 200 and responded in approximately 1.7 seconds.
The affected topic was:
https://meta.appinn.net/t/topic/87672
(The problematic reply has already been removed.)
Suggested improvement
I think it would be useful to either:
- Limit
[details]nesting to a reasonable depth, such as 2 or 3 levels. - Add a site setting, such as
details_max_nesting_depth, allowing administrators to configure the maximum nesting depth.
For backward compatibility, the setting could default to unlimited, while allowing administrators to enforce a limit when needed.
If users exceed the configured limit, Discourse could reject the post with a clear validation message.
Temporary workaround: a plugin
I’ve created a small plugin that limits [details] nesting to a maximum of 2 levels:
GitHub - scavin/discourse-details-depth-limit · GitHub
The plugin validates posts on the server side and rejects posts containing more than two levels of nested collapsible sections.
I’ve tested it successfully in my local Discourse development environment.
For administrators experiencing similar issues, this plugin may serve as a temporary workaround until an official solution becomes available.
I believe a configurable limit in the built-in Details plugin would be a useful safeguard against accidental or excessive nesting.
