Capítulo 439 de 456

Runtime Integration

Core Idea

Clarifies the division of responsibility: the Deployment Adapter API is build-time only (tells the platform what was built and how to route); runtime behavior (request handling, streaming, caching) is handled by the Next.js server plus the cacheHandler/cacheHandlers cache interfaces.

Key Concepts

  • Adapter (build-time): processes build outputs, configures routing, sets up platform infra.
  • Cache Interfaces (runtime): cacheHandler manages ISR/server cache storage and revalidation across instances; cacheHandlers configures 'use cache' directive backends and tag coordination.
  • ctx.waitUntil: passed to Next.js handlers by adapters; accepts a promise, keeps a serverless function alive after response is sent (for background work like cache revalidation).
  • requestMeta.onCacheEntryV2: callback set via addRequestMeta, fires on every cache entry generation/lookup (not just PPR); fires on the instance handling the request, so multi-instance deployments must propagate updates to shared storage.

Key Takeaways

  1. Adapter e cache interfaces juntos formam a superfície completa de integração de plataforma; um não substitui o outro.
  2. ctx.waitUntil é o mecanismo padrão pra trabalho em background após a resposta ser enviada.
  3. Em deploys multi-instância, onCacheEntryV2 só dispara na instância que atendeu a request; propagação pra storage compartilhado é responsabilidade do adapter.

Connects To

  • Invoking Entrypoints (ch440): onde ctx (incluindo waitUntil/requestMeta) é efetivamente passado pro handler.
  • How Revalidation Works (guia): padrões de coordenação de cache multi-instância.