Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Uncaught TypeError: bytes is undefined #3915

Closed
negamaxi opened this issue Oct 8, 2021 · 1 comment
Closed

Uncaught TypeError: bytes is undefined #3915

negamaxi opened this issue Oct 8, 2021 · 1 comment
Labels
need/triage Needs initial labeling and prioritization

Comments

@negamaxi
Copy link
Contributor

negamaxi commented Oct 8, 2021

  • Version: ipfs-core 0.11.1
  • Subsystem: cids ?

Severity: Hight

Description:

As I use ipfs in browser app I've decided to switch to ipfs-core package, but it breakes my app here:

// import { CID } from "ipfs"; <-- This one works
import { CID } from "ipfs-core"; // <-- This one doesn't work

const cidString = 'bafyreib6nqpbzovgi3xmzzcfjpaps6ftaq2vgvbjto6ag3eqmkckhsug3m'

const cidInstance = new CID(cidString); // <-- This line throws an Uncaught TypeError: bytes is undefined

const { value } = await ipfs.dag.get(cidInstance);

I am able to fix this by using CID constructor directly from cids though:

// import { CID } from "ipfs"; <-- This one works
// import { CID } from "ipfs-core";  <-- This one doesn't work
import CID from "cids"; // <-- This one works

ipfs package version I'm switching from: "0.55.4"
ipfs-core core package version I'm switching to: "0.11.1"
cids package version: "1.1.7"

@negamaxi negamaxi added the need/triage Needs initial labeling and prioritization label Oct 8, 2021
@achingbrain
Copy link
Member

The cids module is deprecated, please use multiformats/cid instead.

This is the version exported from ipfs@0.56.x and later, and ipfs-core@0.9.0 and later.

The API is different, that's why you are seeing errors.

When using multiformats/cid you shouldn't use the constructor, instead use .parse if you have a string. E.g.:

`cids` module
const cid = new CID(cidStr)

`multiformats/cid` module
const cid = CID.parse(cidStr)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
need/triage Needs initial labeling and prioritization
Projects
None yet
Development

No branches or pull requests

2 participants