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

Uncaught ReferenceError: _Buffer is not defined #50

Closed
w-ah opened this issue Apr 14, 2022 · 2 comments
Closed

Uncaught ReferenceError: _Buffer is not defined #50

w-ah opened this issue Apr 14, 2022 · 2 comments

Comments

@w-ah
Copy link

w-ah commented Apr 14, 2022

Description
_Buffer is not defined in Node.js. If the program reaches this statement, an error will be thrown and, if uncaught, will crash the node process.

Minimal Reproduction
In Node.js REPL (tested against v16.13.2):

> _Buffer
Uncaught ReferenceError: _Buffer is not defined

Workaround
For Node.js, alias the Buffer global as _Buffer in your program entrypoint so that it is defined before calling anything in bson-objectid:

global['_Buffer'] = Buffer;

Possible Fix
Attempt to use _Buffer, else fall back to using Buffer. Just using normal Buffer global fixes things for Node.js so a global alias is not required.

@w-ah
Copy link
Author

w-ah commented Apr 14, 2022

Not actually sure why _Buffer is being used anyway?

@titanism
Copy link
Contributor

This is fixed and released in v2.0.4 of bson-objectid to npm. Until we have access to master branch of this repository we have published our changes in a fork at https://github.com/cabinjs/bson-objectid.

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