Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make reader lazy on fs.read to run ignore polyfill #168

Merged
merged 3 commits into from
Jan 6, 2025
Merged

Conversation

mabels
Copy link
Contributor

@mabels mabels commented Dec 27, 2024

Hi,

I have a problem with running @ipld/car in Cloudflare workers.
In a lovely world the internal esbuild of wrangler should pick the browser implementation.
But the reality is that wrangler/esbuild picks the node implementation and provides a polyfill for the node
imports that will cause:

const fsread = promisify(fs.read)

this error:

Cannot read properties of undefined (reading 'read')

So I made it lazy and set __browser.

@mabels mabels marked this pull request as ready for review December 27, 2024 17:07
src/reader.js Outdated Show resolved Hide resolved
src/promise-fs-opts.js Outdated Show resolved Hide resolved
src/promise-fs-opts.js Outdated Show resolved Hide resolved
Copy link
Member

@rvagg rvagg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been trying to figure out why __browser is there and I'm scratching my head a bit. I think it's only for tests, to assert that when run in the different environments that it's loading the right thing, but that's only tested from reader.js so I'm not sure it really serves a useful purpose.

But that's probably an issue to resolve some other time!

@rvagg rvagg merged commit ccb8edc into ipld:master Jan 6, 2025
18 checks passed
github-actions bot pushed a commit that referenced this pull request Jan 6, 2025
## [5.4.0](v5.3.3...v5.4.0) (2025-01-06)

### Features

* make reader lazy on fs.read to run ignore polyfill ([#168](#168)) ([ccb8edc](ccb8edc))
Copy link

github-actions bot commented Jan 6, 2025

🎉 This PR is included in version 5.4.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants