next.js
a21b68ab - fix: support calling onClose multiple times in edge-ssr-app (#81911)

Commit
1 year ago
fix: support calling onClose multiple times in edge-ssr-app (#81911) #81389 changed the implementation of `edge-ssr-app`. it added a `RenderOpts.onClose` implemented like this: ```ts let onCloseCallback: (() => void) | undefined const renderOpts = { // ... onClose: (cb) => { onCloseCallback = cb }, } ``` this does not match the behavior of the node implementations of `onClose`, which use `res.on('close', cb)` -- calling this `onClose` multiple times won't work right, because we'll only store the last callback. in practice we currently only call `onClose` once per request, in `AfterContext`, so this *technically works*. but that might change in the future, and it'd break things in surprising ways. to avoid this, i'm changing it to use `CloseController`, which we're already using in other places that need to implement this behavior.
Author
Parents
Loading