logo

Fire-and-Forget

Fire-and-forget is an asynchronous execution pattern where you send a task to a queue and move on immediately — no waiting for a result or completion confirmation. The sending application “fires” the task and “forgets” about it.

How It Works

  1. Your application creates a task with a callback URL and payload
  2. The task is placed in the queue
  3. Your application continues executing without waiting
  4. A worker picks up the task and calls the callback URL in the background

No webhook URL is needed since you don’t expect a result back.

When to Use Fire-and-Forget

This pattern is ideal for work that doesn’t affect the response to the user:

  • Sending emails and notifications — welcome emails, password resets, push alerts
  • Analytics and event tracking — logging user actions, page views, conversion events
  • Cache warming — pre-computing expensive queries for faster future access
  • Cleanup tasks — deleting temporary files, expiring old sessions, purging stale data

Example

// Send a welcome email without waiting for delivery
await aq.tasks.create({
  callbackUrl: 'https://your-app.com/api/send-welcome-email',
  payload: { userId: user.id, email: user.email },
  retries: 3,
});

// Continue immediately — don't wait for the email to send
res.json({ userId: user.id });

Trade-offs

The simplicity of fire-and-forget comes with a caveat: you won’t know if the task failed unless you check. To catch failures, add a webhook URL that triggers when all retries are exhausted, or monitor the dead-letter queue.