Implement Replit reliability patterns including circuit breakers, idempotency, and graceful degradation. Use when building fault-tolerant Replit integrations, implementing retry strategies, or adding resilience to production Replit services. Trigger with phrases like "replit reliability", "replit circuit breaker", "replit idempotent", "replit resilience", "replit fallback", "replit bulkhead".
From replit-packnpx claudepluginhub nickloveinvesting/nick-love-plugins --plugin replit-packThis skill is limited to using the following tools:
Guides Next.js Cache Components and Partial Prerendering (PPR) with cacheComponents enabled. Implements 'use cache', cacheLife(), cacheTag(), revalidateTag(), static/dynamic optimization, and cache debugging.
Migrates code, prompts, and API calls from Claude Sonnet 4.0/4.5 or Opus 4.1 to Opus 4.5, updating model strings on Anthropic, AWS, GCP, Azure platforms.
Details PluginEval's skill quality evaluation: 3 layers (static, LLM judge), 10 dimensions, rubrics, formulas, anti-patterns, badges. Use to interpret scores, improve triggering, calibrate thresholds.
Production reliability patterns for applications hosted on Replit. Replit's container-based hosting, automatic sleep behavior, and ephemeral filesystem require specific resilience strategies for production workloads.
Replit containers restart on deploy and after sleep. Pre-warm caches and connections on startup.
import time
startup_complete = False
startup_time = None
async def warmup():
global startup_complete, startup_time
startup_time = time.time()
# Pre-load frequently accessed data
await cache.warm(["config", "feature_flags", "templates"])
# Verify database connection
await db.ping()
startup_complete = True
@app.route('/health')
def health():
if not startup_complete:
return {"status": "warming_up"}, 503 # HTTP 503 Service Unavailable
return {"status": "ok", "uptime": time.time() - startup_time}
@app.before_first_request
async def on_startup():
await warmup()
Never rely on local filesystem for state that must survive container restarts.
from replit.object_storage import Client as ObjectStorage
import json
class PersistentState:
def __init__(self):
self.storage = ObjectStorage()
self._cache = {}
def save(self, key: str, data: dict):
self.storage.upload_from_text(
f"state/{key}.json",
json.dumps(data)
)
self._cache[key] = data
def load(self, key: str) -> dict:
if key in self._cache:
return self._cache[key]
try:
raw = self.storage.download_as_text(f"state/{key}.json")
data = json.loads(raw)
self._cache[key] = data
return data
except:
return {}
For Repls not using Deployments, prevent sleep with an external health check ping.
# Internal: expose health endpoint
@app.route('/ping')
def ping():
return "pong", 200 # HTTP 200 OK
# External: use a free cron service to ping every 5 minutes
# cron-job.org, UptimeRobot, or similar
# URL: https://your-repl.replit.app/ping
# Interval: 5 minutes
Replit sends SIGTERM before container stop. Save state during shutdown.
import signal, sys
def graceful_shutdown(signum, frame):
print("Shutting down gracefully...")
state.save("session", {"last_active": time.time()})
db.close()
sys.exit(0)
signal.signal(signal.SIGTERM, graceful_shutdown)
| Issue | Cause | Solution |
|---|---|---|
| Data loss on restart | Using local filesystem | Use Replit DB or Object Storage |
| Slow first request | Cold start | Pre-warm on startup, show loading state |
| Container sleeping | No activity for 30 min | Use Deployments or external keep-alive |
| Database disconnects | Container restart | Reconnect on startup, connection pooling |
health = {
"container_uptime": time.time() - startup_time,
"db_connected": await db.ping(),
"storage_available": storage.exists("state/"),
"memory_mb": process.memory_info().rss / 1024 / 1024 # 1024: 1 KB
}