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

Commit causing Buffer error when executing in browser, not Node environment #133

Open
willjstevens opened this issue May 18, 2024 · 3 comments

Comments

@willjstevens
Copy link

This commit (line 36 in retrieve.js) breaks the extract call is giving the following error when executing in a browser such as Chrome:

Uncaught (in promise) ReferenceError: Buffer is not defined at __WEBPACK_DEFAULT_EXPORT__ (retrieve.js:58:1) at async extract

Screenshot 2024-05-18 at 3 19 16 PM

The reason is that Buffer object is only available in a Node environment, not in a browser library.

You either want to rewrite it to not depend on that Node Buffer class or rewrite the line something like:

const text = (buffer && Buffer) ? Buffer.from(buffer).toString().trim() : ''

@ndaidong
Copy link
Collaborator

@willjstevens this library's browser support is quite limited, making it nearly unusable in that environment. Considering this, would it be best to remove browser compatibility from the project's scope for now?

@willjstevens
Copy link
Author

Well, I have been using it in the browser for testing and analysis, in addition to a backend-Node environment. Limiting it to Node only would only inhibit from other use cases; might cause people to go elsewhere. This is also a JavaScript library and theoretically, anything written in JavaScript should function in any JavaScript engine (browser or Node.) Requiring Node, if anything, could be handled by externalizing Node-only components to external module, over marking as Node only. This would give people choice of how to use it.

This library is nice and is useful. I recommend not limiting it. Just try to rewrite the line above. Or ask, 'is that Buffer optimization necessary?' Or how could it be handled differently?, etc. BTW - thanks for your work on this helpful project.

@ndaidong
Copy link
Collaborator

@willjstevens ok, let me see how we should deal with buffer at the client side.

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

No branches or pull requests

2 participants