Netlify dev working locally but erroring out when deploying to netlify edge

I’ve a simple netlify edge function which is working locally using netlify dev but when I am deploying it to the netlify it’s erroring out saying worker

Dec 17, 04:32:54 PM: error  ReferenceError: Worker is not defined
import { getJsDelivrBundles, selectBundle, ConsoleLogger, AsyncDuckDB } from "";
import { Int } from "";
const JSDELIVR_BUNDLES = getJsDelivrBundles();
const bundle = await selectBundle(JSDELIVR_BUNDLES);
const worker_url = new URL(bundle.mainWorker!, import.meta.url).href;

const worker = new Worker(worker_url, { type: 'module' })
const logger = new ConsoleLogger();
const db = new AsyncDuckDB(logger, worker);
await db.instantiate(bundle.mainModule, bundle.pthreadWorker);

const res = await fetch('');
await db.registerFileBuffer('taxi_2019_04.parquet', new Uint8Array(await res.arrayBuffer()));
BigInt.prototype.toJSON = function () { return this.toString() }

export default async function handler(req: Request, context: Context) {
    const conn = await db.connect();
    const arrowResult = await conn.query<{total_count: Int}>(`SELECT COUNT(*) AS total_count
                                            FROM 'taxi_2019_04.parquet'
                                            WHERE pickup_at BETWEEN '2019-04-15' AND '2019-04-20'`)
    const result = arrowResult.toArray().map((row) => row.toJSON());
    return Response.json(result[0]);

export const config: Config = {
    path: "/duckdb",

Can you bundle this together as a repo that we can use to test and debug?

Sure… here is the sample repo

Interestingly, I tried to deploy your repo and it seems to work without any changes: main–

How are you getting the error?