DNS Manager creates records too quicky; fails when rate limited

Issue Description

When creating the records on a new instance, stalwart will create several records in a row one after another:

If there are too many requests in a row, porkbun throws a 503 error:

Failed to set DNS RRSet for mydomain.com./TXT: Failed to set DNS RRSet: API error: BadRequest {"status":"ERROR","message":"Edit error: We were unable to edit the DNS record.","code":"EDIT_ERROR_WE_WERE_UNABLE_TO_EDIT_THE_DNS_RECORD","requestId":""}; Failed to set DNS RRSet for autodiscover.mydomain.com./CNAME: Failed to set DNS RRSet: API error: HTTP 503: <html>\r\n<head><title>503 Service Temporarily Unavailable</title></head>\r\n<body>\r\n<center><h1>503 Service Temporarily Unavailable</h1></center>\r\n<hr><center>openresty</center>\r\n</body>\r\n</html>

There doesn’t seem to be any config option to have stalwart slow down inbetween requests.

Expected Behavior

Domain tasks either slows down to protect against rate limits.

Actual Behavior

The entire DNS management task fails.

Reproduction Steps

  1. Configure stalwart to use porkbun on a fresh domain

Stalwart Version

v0.16.x

Installation Method

Binary (Linux)

Database Backend

PostgreSQL

Blob Storage

S3-compatible

Search Engine

Internal

Directory Backend

Internal

Additional Context

Reverse proxy via nginx

I have reviewed the documentation and FAQ and confirm that my issue is NOT addressed there.

on

I have searched this support forum (open and closed topics) and confirm this is not a duplicate.

on

I understand that topics in this category are triaged by a bot first but a human reply will follow up. If I’d prefer a human-only reply, I’ll add the no-ai tag to my topic.

on

This is a confirmed gap in the current implementation. Looking at the source code and documentation, there is currently no per-request delay or throttling option in the DnsServer configuration for Porkbun (or any other provider). The DNS management task fires all set_rrset calls sequentially in a tight loop with no sleep between them, which is exactly the behavior you’re hitting.

The available DnsServer fields for Porkbun are:

  • timeout – per-request timeout (default 30s)
  • ttl – TTL on created records (default 5m)
  • pollingInterval – how often to check propagation (default 15s)
  • propagationTimeout – how long to wait for propagation (default 1m)
  • propagationDelay – initial delay before the first propagation check (useful for slow providers, but this is post-creation, not between API calls)

None of these introduce a delay between individual API calls, so there is no configuration-side workaround to throttle the burst toward Porkbun’s API. This is a code-level limitation in crates/services/src/task_manager/dns.rs.

A human staff member will need to evaluate adding an inter-request delay or retry-with-backoff logic for 429/503 responses from DNS providers.

Reference: DnsServer object documentation

This is an automated reply from the Stalwart Help Bot. Other community members may follow up if this answer is incomplete or wrong.

This has been fixed on the main branch. The fix will be included in v0.16.8.

I am using version v0.16.9, and the problem persists. I am experiencing an issue with Cloudflare.
The installation was performed using install.sh --fdb.