Closed meech-ward closed 1 year ago
Hi, thank you for reporting this issue! It indeed seems that Vercel Edge Functions don't support queueMicrotask
, so I will add a workaround and release a new version, hopefully on Monday and Tuesday.
(I will also have a look on how we could do automated smoke tests of the client library on Vercel Edge Functions)
Vercel Edge Functions do support queueMicrotask
. I didn't realize that Cloudflare workers have supported queueMicrotask
for years now.
I should have tested this a little further, but queueMicrotask
is undefined only during local development of a next app, not once it's deployed, so this is actually a next issue.
export const runtime = "edge";
export default async function Home() {
return typeof queueMicrotask
}
This page will render undefined
when developing locally, but function
once deployed to vercel.
I tested this using next@latest
which is currently 13.4.4. In this version of next, queueMicrotask is undefined so libsql-client
doesn't work. If you upgrade to next@canary
which is currently 13.4.5-canary.9, then queueMicrotask is defined and everything works.
next@13.4.4
works with libsql-client@0.1.6
next@13.4.5-canary.9
works with libsql-client 0.2.0
This issue won't exist for long, but for anyone building a next.js app with libsql, this is the solution to ReferenceError: queueMicrotask is not defined
Thank you for the clarification :) I managed to reproduce this locally. I released a new version 0.4.1 of @libsql/hrana-client
, which ponyfills queueMicrotask()
if it is undefined. A npm update
should fetch the new version and resolve the issue for you.
It indeed seems that on the actual Vercel Edge runtime, the queueMicrotask()
function is defined, even though they don't list it in the list of supported APIs:
https://vercel.com/docs/concepts/functions/edge-functions/edge-runtime
Thank you again for reporting this issue! Feel free to reopen it if you encounter further issues.
Version 0.2.0 throws
ReferenceError: queueMicrotask is not defined
when using'@libsql/client/http'
from a vercel edge function cloudflare worker.Downgrading to Version 0.1.6 fixes this issue.
The recent 0.2.0 update uses hrana-client-ts version 0.4.0 which uses
queueMicrotask
in https://github.com/libsql/hrana-client-ts/blob/main/src/http/stream.ts.Version 0.1.6 uses hrana-client-ts version 0.3.10 which doesn't use
queueMicrotask
.