Skip to content

Glitch/TypeError: Received Buffer when Uint8Array expected #259

Description

@telamon

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions