FAQ & Troubleshooting

Common questions, issues, and solutions when working with Azu.

Frequently Asked Questions

General Questions

Q: What makes Azu different from other web frameworks?

A: Azu emphasizes compile-time type safety and contract-first development. Unlike traditional frameworks that validate at runtime, Azu catches errors during compilation, resulting in more reliable applications with zero runtime overhead for type checking.

Q: Can I use Azu for production applications?

A: Yes! Azu is built for production use with performance optimizations, comprehensive error handling, and scalability features. Many applications are successfully running Azu in production environments.

Q: How does Azu compare to other Crystal web frameworks?

A: Azu focuses on type-safe contracts and real-time features, while frameworks like Kemal prioritize simplicity. Azu provides more structure and compile-time guarantees at the cost of some flexibility.

Q: Do I need to learn Crystal to use Azu?

A: Yes, basic Crystal knowledge is required. However, Crystal's syntax is similar to Ruby, making it approachable for developers from many backgrounds.

Technical Questions

Q: How do I handle database connections in Azu?

A: Azu doesn't include a built-in ORM. You can use any Crystal database library like crystal-db, granite, or jennifer.cr:

require "pg"
require "azu"

struct UserEndpoint
  include Azu::Endpoint(UserRequest, UserResponse)

  get "/users/:id"

  def call : UserResponse
    DB.open("postgres://localhost/mydb") do |db|
      user = db.query_one("SELECT * FROM users WHERE id = $1",
                         params["id"], as: User)
      UserResponse.new(user)
    end
  end
end

Q: Can I use Azu with existing Crystal libraries?

A: Absolutely! Azu is designed to work with the Crystal ecosystem. You can use any Crystal shard or library within your Azu applications.

Q: How do I handle authentication?

A: Implement authentication using middleware:

Q: How do I deploy Azu applications?

A: Compile your application and deploy the binary:

Common Issues

Compilation Issues

Problem: "can't infer type" errors

Problem: Template compilation errors

Solution: Check template paths in configuration:

Runtime Issues

Problem: WebSocket connections not working

Symptoms:

  • WebSocket connection fails

  • No error messages in logs

  • Client can't connect

Solutions:

  1. Check WebSocket route registration:

  1. Verify middleware order:

  1. Check client-side connection:

Problem: Request validation not working

Symptoms:

  • Validation rules ignored

  • Invalid data passes through

Solutions:

  1. Ensure validation is called:

  1. Check validation rules syntax:

Problem: File uploads not working

Symptoms:

  • File uploads fail silently

  • Uploaded files are empty

  • Memory issues with large files

Solutions:

  1. Configure upload limits:

  1. Handle multipart data correctly:

Performance Issues

Problem: Slow response times

Diagnosis:

  1. Enable request logging:

  1. Check for blocking operations:

Problem: Memory leaks

Common causes:

  • Not cleaning up file uploads

  • Keeping references to WebSocket connections

  • Large object creation in loops

Solutions:

  1. Clean up resources:

  1. Manage WebSocket connections:

Development Issues

Problem: Hot reload not working

Solutions:

  1. Enable in configuration:

  1. Check file permissions and paths:

Problem: CORS issues in development

Symptoms:

  • Browser blocks requests from frontend

  • CORS errors in console

Solution:

Debugging Tips

Enable Debug Logging

Inspect Request Data

Use Crystal's Built-in Debugging

Test Individual Components

Performance Troubleshooting

Profile Your Application

Monitor Memory Usage

Database Query Optimization

Getting Help

Community Resources

Reporting Issues

When reporting issues, include:

  1. Crystal version: crystal version

  2. Azu version: Check shard.yml

  3. Minimal reproduction case

  4. Error messages and stack traces

  5. Environment details (OS, deployment method)

Example Issue Report

Error: Connection refused when trying to connect to ws://localhost:4000/test

Expected: WebSocket connection should succeed

Last updated

Was this helpful?