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

Glitch/TypeError: Received Buffer when Uint8Array expected #259

Open
telamon opened this issue Jul 11, 2023 · 1 comment
Open

Glitch/TypeError: Received Buffer when Uint8Array expected #259

telamon opened this issue Jul 11, 2023 · 1 comment

Comments

@telamon
Copy link

telamon commented Jul 11, 2023

This bug affects nodejs/test-environments

Excerpt from block.js

const bytes = codec.encode(value) // <-- Returns node:Buffer
const hash = await hasher.digest(bytes) // !!! <-- Throws if not Uint8Array

Platform agnostic proposal:

let bytes = codec.encode(value)
if (!(bytes instanceof Uint8Array) && bytes?.buffer) bytes = new Uint8Array(bytes.buffer, bytes.byteOffset, bytes.byteLength)
const hash = await hasher.digest(bytes)

I'll monkeypatch for now.
Please take it from here, thanks.

@tabcat
Copy link
Contributor

tabcat commented Jul 11, 2023

Somewhat related to #191

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