You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems that in a browser environment, anything defined as Buffer on the window object, even if it's not a complete buffer implementation, causes the library to crash.
In my case, window.Buffer contains a Buffer implementation which doesn't support allocUnsafeSlow, but this could be any definition of Buffer, such as window.Buffer = {}. I don't have the option to remove the Buffer definition from the global scope.
A possible solution might be to perform stricter checks on globalThis.Buffer to ensure allocUnsafeSlow exists before using it. Alternatively, it may be safer to introduce an option to explicitly disable the Node.js Buffer usage, which could be enabled or disabled in browser environments.
The text was updated successfully, but these errors were encountered:
It seems that in a browser environment, anything defined as
Buffer
on thewindow
object, even if it's not a complete buffer implementation, causes the library to crash.Relevant code:
https://github.com/kriszyp/cbor-x/blob/master/encode.js#L8
In my case,
window.Buffer
contains aBuffer
implementation which doesn't supportallocUnsafeSlow
, but this could be any definition ofBuffer
, such aswindow.Buffer = {}
. I don't have the option to remove theBuffer
definition from the global scope.A possible solution might be to perform stricter checks on
globalThis.Buffer
to ensureallocUnsafeSlow
exists before using it. Alternatively, it may be safer to introduce an option to explicitly disable the Node.jsBuffer
usage, which could be enabled or disabled in browser environments.The text was updated successfully, but these errors were encountered: