fix(ext/node): export File class from node:buffer module#32182
Open
veeceey wants to merge 2 commits intodenoland:mainfrom
Open
fix(ext/node): export File class from node:buffer module#32182veeceey wants to merge 2 commits intodenoland:mainfrom
veeceey wants to merge 2 commits intodenoland:mainfrom
Conversation
Node.js 20+ exports the File class (which extends Blob) from the
buffer module. Deno's node:buffer polyfill was missing this export,
causing runtime errors in frameworks like Next.js edge runtime that
depend on `require('buffer').File` being available.
Fixes denoland#28120
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Node.js 20+ exports the
Fileclass from thebuffermodule. Currently Deno'snode:bufferpolyfill exportsBlobbut notFile, which causes runtime errors like:This breaks frameworks that rely on
require('buffer').File, such as Next.js with edge runtime (via Vercel'sedge-runtimepackage).The fix imports and re-exports the existing
Fileclass (fromext:deno_web/09_file.js, which already definesFile extends Blob) through the buffer polyfill chain:ext/node/polyfills/internal/buffer.mjs- import and add tomodexportsext/node/polyfills/buffer.ts- re-exportext/node/polyfills/internal/buffer.d.ts- add type declarationsAdded a test in
tests/unit_node/buffer_test.tsthat verifiesFileis correctly exported and constructable fromnode:buffer.Closes #28120