earthstar-project / earthstar

Storage for private, distributed, offline-first applications.
https://earthstar-project.org
GNU Lesser General Public License v3.0
633 stars 20 forks source link

TypeError: The input must be a Uint8Array, a string, or an ArrayBuffer. Received a value of the type undefined. #355

Closed Vicente015 closed 1 month ago

Vicente015 commented 1 month ago

What's the problem you want solved?

Hey, I'm having some problems when I try to mint a new cap for a recently created share (not communal), these errors seems to be related with the ANY_SUBSPACE symbol.

I'm using the latest earthstar version with: RuntimeDriverUniversal and StorageDriverIndexedDB.

I'm having the following error:

Uncaught (in promise) TypeError: The input must be a Uint8Array, a string, or an ArrayBuffer. Received a value of the type undefined.
    validateBinaryLike _validate_binary_like.ts:24
    encodeBase32 base32.ts:190
    encodeBase322 base32.ts:7
    encodeCinn25519PublicKeyDisplay cinn25519.ts:176
    encodeIdentityTag identity.ts:86
    _Cap cap.ts:63
    mintCap peer.ts:373
    createShare Earthstar.tsx:87
    handleSubmit AskModal.tsx:19
    onSubmit AskModal.tsx:23
    ...

I tried doing some debugging on the browser and I found the following: The error happens because encodeIdentityTag on identity.ts:86 is being called even when grantedArea.includedSubspaceId === ANY_SUBSPACE for some reason symbol comparison is not working?, then encodeCinn25519PublicKeyDisplay on cinn25519.ts:176 is called and because publicKey.underlying is undefined it produces an error

Screenshot from 2024-07-21 13-31-50

Screenshot from 2024-07-20 21-21-33

I tried to recreate the issue on Deno and it looks like this just happens on browser

Is there a solution you'd like to recommend?

Vicente015 commented 1 month ago

@sgwilym okay I think I found the cause of the error, this is also happening on Nodejs

The latest earthstar published version is using willow-utils@1.0.0 but using meadowcap@0.6.3 that uses willow-utils@2.0.0 so in this.grantedIdentity = grantedArea.includedSubspaceId === ANY_SUBSPACE it is comparing different symbols because the grantedArea.includedSubspaceId is from a different willow-utils version

So this should be fixed if you release a new version with the updated dependencies :)

sgwilym commented 1 month ago

Thank you for catching and diagnosing this! I have release 11.0.0-beta.5 with updated deps, please let me know if that resolves your issue.

Vicente015 commented 1 month ago

The issue is fixed! thank you :smiley: