ts-odd icon indicating copy to clipboard operation
ts-odd copied to clipboard

Implement safer guards against missing properties.

Open jeffgca opened this issue 2 years ago • 0 comments

Summary

When I link a new Firefox browser, I reliably see this error in the console:

Uncaught (in promise) TypeError: can't access property "cid", a.metadata is undefined
    r basic.ts:54
    wT basic.ts:43
    fromInfo PublicTree.ts:78
    fromCID PublicTree.ts:73
    getDirectChild PublicTree.ts:167
    getOrCreateDirectChild tree.ts:184
    mkdirRecurse tree.ts:56
    mkdirRecurse tree.ts:63
    mkdir tree.ts:46
    webnative filesystem.ts:219
...
    bootElm https://auth.fission.codes/index.js:1
    AsyncFunctionNext self-hosted:668
    (Async: async)
    <anonymous> https://auth.fission.codes/index.js:1
    AsyncFunctionNext self-hosted:668
    (Async: async)
    <anonymous> https://auth.fission.codes/index.js:1

This error seems to be from this line of code:

    const f = await ipfs.encoded.catAndDecode(
      decodeCID(innerLinks["metadata"].cid),
      null
    )

https://github.com/fission-suite/webnative/blob/38d3818102dca88d7ddb963ee89e0b4ff93481aa/src/fs/protocol/basic.ts#L55

It looks like we code be more defensive in trying to access the .cid property in order for there to be a better error for developers to encounter when troubleshooting WNFS initialization issues. If there is a common root cause for this error, we should try to help the developer and point them in the right direction.

jeffgca avatar Jul 26 '22 21:07 jeffgca