Skip to content

Deploying larger compiled packages can fail during base64 encoding #8

Description

@omerbek

Summary

Deploying a compiled contract can fail before useDeploy() is called when the compiled package is large enough.

ContractList converts contract.packageBytes to base64 with:

btoa(String.fromCharCode(...contract.packageBytes))

Spreading a large Uint8Array into String.fromCharCode() is limited by the JavaScript engine's maximum argument count. Once the compiled package crosses that threshold, the click handler throws synchronously with RangeError: Maximum call stack size exceeded and the deploy flow never starts.

Repro

This is the same conversion pattern used by the deploy button:

node -e "const b=new Uint8Array(200000); String.fromCharCode(...b)"

It fails with:

RangeError: Maximum call stack size exceeded

Impact

A contract can compile successfully and still be impossible to deploy from the UI solely because its .masp package is too large for the spread call. The deploy hook already accepts base64, so this is only an encoding issue in the UI boundary.

Suggested fix

Encode the Uint8Array in chunks, or move a safe uint8ArrayToBase64() helper into a shared utility and use it from ContractList.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions