Middleware fault tolerance
Middleware fault tolerance
Section titled “Middleware fault tolerance”One of the most important guarantees Appwarden provides is that our middleware will never break your domain. Even if Appwarden is misconfigured or unresponsive, your website will always be available to your users (unless it is quarantined). This is achieved through the same built-in failsafe mechanisms on both Cloudflare and Vercel platforms.
How It Works
Section titled “How It Works”On both Cloudflare and Vercel, Appwarden middleware uses the ctx.passThroughOnException() API. This critical feature ensures that if the middleware encounters any unhandled exception, the platform automatically bypasses the middleware and serves your original website directly.
export default { async fetch(request, env, ctx) { // Enable automatic passthrough on any unhandled exception ctx.passThroughOnException()
try { // Appwarden middleware logic here return await processRequest(request, env) } catch (error) { // If any error occurs, Cloudflare automatically // serves the original request without middleware throw error } },}Cloudflare
Section titled “Cloudflare”You can see this implementation in action in our Cloudflare runner code.
Vercel
Section titled “Vercel”You can see this implementation in action in our Vercel runner code.
What This Means for You
Section titled “What This Means for You”Complete Protection Against Outages
Section titled “Complete Protection Against Outages”- API failures: If Appwarden’s API is unreachable, your site continues to work normally
- Configuration errors: Misconfigured middleware won’t prevent your site from loading
- Network latency: Slow or failed network requests never add additional latency to your visitors
- Network timeouts: Slow or failed network requests won’t block your visitors
- Code bugs: Even if there’s an issue in the middleware code, your site stays online
Zero Downtime Risk
Section titled “Zero Downtime Risk”Unlike some security solutions that can create single points of failure, Appwarden middleware is designed with a “fail-open” approach. Your website’s availability is never compromised by the security layer.
Transparent Operation
Section titled “Transparent Operation”When everything is working correctly, the middleware operates transparently. When something goes wrong, it becomes completely transparent by automatically stepping aside.
Best Practices
Section titled “Best Practices”While the middleware is designed to be failsafe, following these practices ensures optimal performance:
- Test your configuration in a staging environment before deploying
- Keep your middleware package updated to benefit from the latest improvements
- Use proper environment variables to avoid configuration-related issues
If you have questions about middleware reliability or want to discuss specific scenarios, join our community and we’ll be happy to help.
