Refactor use of AsyncLocalStorage (#44668)
Previously we were targeting lower versions of Node.js for `app` directory support, but a higher version of Node.js (with support for `AsyncLocalStorage`) was made required to use `undici` instead of `node-fetch`. This PR serves to: 1. Simplify the usage of those storage objects by removing the unnecessary fallback code. Everything now just uses the native `AsyncLocalStorage` interface. 2. Isolates the initialization of each store within it's own bound context to prevent leakage. 3. Adds immutibility flags to variables that should only be initlaized once upon store creation to prevent errors. This actually revealed some bugs in the implementation that were corrected. In the event that this was in error, the following adapter could be used to simulate the previous beheviour with minor changes to the present implementation ([see this gist](https://gist.github.com/wyattjoh/6f3dffb99a4ac1a8254c90284f05026a)). [Slack Reference](https://vercel.slack.com/archives/C04DUD7EB1B/p1673030967568029)
Showing
This diff is collapsed.
Please
register
or
sign in
to comment