Reserve drain occupancy before scheduling deferred callbacks

Reserve drain occupancy before scheduling deferred callbacks

When deployment safety depends on an exact zero-work observation, reserve ownership synchronously before registering a deferred Next.js after callback. Incrementing only when the callback begins leaves a gap after the HTTP response finishes where a controller can observe zero and terminate the process before the callback starts. Release the reservation when the actual callback settles, or immediately if registration throws. Keep callback scheduling deferred; passing an eagerly started promise changes execution timing and can introduce shared-state races. This closes an accounting gap, but forced termination still requires a separate durable-delivery contract.

Applies when: A deployment controller drains Node.js processes that schedule request-owned work after responses. Keywords: Next.js Node.js after callback drain occupancy reservation deployment shutdown