Skip to content

Cannot use @vercel/blob in Edge runtime #552

Description

@yuriyyakym

Whereas everything works fine locally while vercel dev, it throws an error when I try to deploy my function using vercel deploy:

Error: The Edge Function "api/pronunciation" is referencing unsupported modules:
	- @fastify: node:stream
	- undici: stream, net, http, tls, querystring, stream/web, util/types, worker_threads, zlib, perf_hooks, console, url, diagnostics_channel

I have found the following comments in this repository:

// When bundled via a bundler supporting the `browser` field, then
// the `undici` module will be replaced with https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
// for browser contexts. See ./undici-browser.js and ./package.json
import { fetch } from 'undici';

and

// this file gets copied to the dist folder
// it makes undici work in the browser by reusing the global fetch
// it's the simplest way I've found to make http requests work in Node.js, Serverles Functions, Edge Functions, and the browser
// this should work as long as this module is used via Next.js/Webpack
// moving forward we will have to solve this problem in a more robust way
// reusing https://github.com/inrupt/universal-fetch
// or seeing how/if cross-fetch solves https://github.com/lquixada/cross-fetch/issues/69
export const fetch = globalThis.fetch.bind(globalThis);


Am I missing any config to make vercel deploy use the browser version file?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions