Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
With [waitUntil](https://vercel.com/docs/functions/functions-api-reference#waituntil) the lambda execution continues until all async tasks (like sending data to Sentry) are done. Timing-wise it should work like this: `span.end()` -> `waitUntil()` -> Nitro/Node `response.end()` The problem in [this PR](#13895) was that the Nitro hook `afterResponse` is called to late (after `response.end()`), so `waitUntil()` could not be added to this hook. --- Just for reference how this is done in Nitro (and h3, the underlying http framework): 1. The Nitro `afterResponse` hook is called in `onAfterResponse` https://github.com/unjs/nitro/blob/359af68d2b3d51d740cf869d0f13aec0c5e9f565/src/runtime/internal/app.ts#L71-L77 2. h3 `onAfterResponse` is called after the Node response was sent (and `onBeforeResponse` is called too early for calling `waitUntil`, as the span just starts at this point): https://github.com/unjs/h3/blob/7324eeec854eecc37422074ef9f2aec8a5e4a816/src/adapters/node/index.ts#L38-L47 - `endNodeResponse` calls `response.end()`: https://github.com/unjs/h3/blob/7324eeec854eecc37422074ef9f2aec8a5e4a816/src/adapters/node/internal/utils.ts#L58
- Loading branch information