Top Level await issue with latest [email protected], mysql2, planetscale
We are getting this error when following the release notes recommended setup for pscale/mysql:
5 Replies
We are using Remix.run and Node v18.6.0, here is our exact implementation:
Top-level await is not available in the configured target environment ("node14")You're not running on Node 18
we are, but we figured out the issue and a solution. I'm gathering this information now for others in the future.
This is what we did to solve this:
Vercel uses undici for fetch on the server, which doesn't seem to be fully compatible with node 18. So, in serverless functions, we get this error when using drizzle: Unhandled Promise Rejection {"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"TypeError: First parameter has member 'readable' that is not a ReadableStream."
To fix this, in the @planetscale/database connect config we can set the fetch property to use fetch-ponyfill.
You have no clue how much I love you for this. It was driving me crazy!
Drove us crazy too.