Skip to content

uploadData on an empty Buffer throws confusing error #1232

Description

@Cafe137
<anonymous_script>:1
�
^

SyntaxError: Unexpected token '', "�"... is not valid JSON
    at JSON.parse (<anonymous>)
    at toBeeResponse (/Users/aron/Code/Swarm/correctness/node_modules/.pnpm/@ethersphere+bee-js@12.3.1/node_modules/@ethersphere/bee-js/dist/cjs/utils/http.js:120:32)
    at process.processTicksAndRejections (node:internal/process/task_queues:103:5)
    at async Object.upload (/Users/aron/Code/Swarm/correctness/node_modules/.pnpm/@ethersphere+bee-js@12.3.1/node_modules/@ethersphere/bee-js/dist/cjs/modules/bytes.js:25:22)
    at async uploadWithBeeJs (/Users/aron/Code/Swarm/correctness/src/index.ts:58:28)
    at async main (/Users/aron/Code/Swarm/correctness/src/index.ts:24:23)

Node.js v24.13.0

Probably reproducible with an empty string, too

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High: Likely tackled by core team if no one steps updif:mediumPrior experience is likely helpfulkind:bugA bug in existing code (including security flaws)

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions