Background Jobs

Background Jobs

Background jobs are powered by Inngest. Use jobs for workflows that should not block a request, such as credit expiration, delivery retries, email batching, or async product processing.

Main files

PathPurpose
src/inngest/client.tsInngest client
src/inngest/functions.tsFunction definitions
src/inngest/index.tsExports
src/app/api/inngest/route.tsInngest route handler
src/app/api/jobs/credits/expire/route.tsCredit expiration job endpoint
src/test/jobs/cron-expire.test.tsJob test coverage

Local development

Start the app:

pnpm dev

Then use the Inngest dev server if you need to inspect or trigger functions locally.

Production variables

VariablePurpose
INNGEST_EVENT_KEYSends events to Inngest
INNGEST_SIGNING_KEYVerifies requests from Inngest

Job design rules

  • Keep jobs idempotent.
  • Store enough state to recover from retries.
  • Do not grant credits or change subscription state twice for the same external event.
  • Prefer small composable functions over one large workflow.
  • Log job identifiers and external event IDs.

Testing

Run job tests after touching expiration logic:

pnpm test:run src/test/jobs

On this page