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.
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 } },}You can see this implementation in action in our Cloudflare runner code.
You can see this implementation in action in our Vercel runner code.
- 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
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.
When everything is working correctly, the middleware operates transparently. When something goes wrong, it becomes completely transparent by automatically stepping aside.
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.