Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Glitch/TypeError: Received Buffer when Uint8Array expected #259

@telamon

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.

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