-
Notifications
You must be signed in to change notification settings - Fork 1.2k
IPFS ^0.50.2 digest should be a Uint8Array when used in node.js #3313
Comments
Thank you for submitting your first issue to this repository! A maintainer will be here shortly to triage and review.
Finally, remember to use https://discuss.ipfs.io if you just need general support. |
I am continuing to investigate as I suspect this is user error but wanted to document this after 8+ hours of trying to get my example code to run as I expected. |
There's something strange going on with jest/typescript in your project as with this setup node If I refactor your code to just be plain js and run it in your project dir it works as expected (well, sort of - it errors because you have only specified webrtc swarm addresses and webrtc is not enabled by default under node.js as it's only really intended to be used in the browser - use tcp or websockets in node instead): async function main () {
const IPFS = require('ipfs');
const ipfs = await IPFS.create({
repo: 'ipfs-' + Math.random(),
config: {
Addresses: {
Swarm: [
// This is a public webrtc-star server
'/dns4/wrtc-star1.par.dwebops.pub/tcp/443/wss/p2p-webrtc-star',
'/dns4/wrtc-star2.sjc.dwebops.pub/tcp/443/wss/p2p-webrtc-star',
'/ip4/127.0.0.1/tcp/13579/wss/p2p-webrtc-star'
]
},
// If you want to connect to the public bootstrap nodes, remove the next line
Bootstrap: []
}
})
await ipfs.stop()
}
main()
.catch(e => {
console.error(e)
process.exit(1)
}) |
Thanks for the reply. I am jumping back on this now. I am realizing my environment is incorrect and I brilliantly installed node side by side to my node version manger. So this is one issue I resolved in the environment... I rebuilt the project and re-ran the unit test. Related solution I will post the solution working in the repository and close this out. I really appreciate the reply @achingbrain! https://github.com/ipfs-inactive/jest-environment-aegir |
Thanks for the link to the jest issue, I guess it's still an issue with that test runner. |
yarn jsipfs version --all
yarn run v1.22.4
$ C:\js-storage-chain\node_modules.bin\jsipfs version --all
js-ipfs version: 0.50.2-99c762ba6b3b71e07596b2930c09fb143451aafe
interface-ipfs-core version: ^0.140.0
ipfs-http-client version: ^47.0.1
Repo version: 9
System version: x64/win32
Node.js version: v12.16.3
Commit: 99c762b
✨ Done in 1.51s.
$ uname -a MINGW64_NT-10.0 DESKTOP-PVGQUPP 2.11.2(0.329/5/3) 2018-11-10 14:38 x86_64 Msys
]Not running this in the browser but rather using node.js for the work. Using Jest as my testing library which I hope is not the core issue I am having.
JS-IPFS
Severity:
High - IPFS JS create functionality is broken it seems, or I am misusing by running in Jest test environment.
Description:
** What I did:**
I am working on making AWS S3 enabled secure private network as a project PoC for what I hope to build into a monetizable set of products so I can support IPFS and like protocols because I believe this is the future!
I worked on getting my node to connect to the datastore-s3 yet realized after much trial and error it was not behaving as it had prior running an unknown older ipfs version because I am a noob. I downloaded the datastore dependencies and botched them. Yet realized the error came from the recent breaking change Node.js Buffer to UTF8IntArrays, as mentioned in the weekly sync.
So I ran the code without any data-store dependencies and it had the same error in the latest version. I tried a couple others newer and older to 0.50.0. I want the new functionality this network upgrade provides so I am willing to help fix and do what I need to do to see this through.
I made a new branch and validated much of my work and stripped out the dependencies aside from TypeScript, and Jest, and rimraf.
I still get the error in my create unit test.
I wrapped the IPFS creation logic to match my serverless goals with the node using an AWS S3 bucket, yet used copy paste code in the end to prove I was getting some issues.
What happened
What you expected to happen
I expected the IPFS node to be generated without error. Yet the jsipfs commands are not behaving as I expected.
Steps to reproduce the error:
https://gitlab.com/TraiforceGroupLLC/js-storage-chain/-/tree/ipfs-utf8-error/src/libraries/ipfs-aws-s3
pull repo and run yarn test.
Index.ts
export interface IIPFSAWSS3 {
createOrConnect(path:string, awsS3Bucket: string): Promise;
createMultiAddress(ip: string, peerIdHash: string, ipv6: boolean): string;
};
export default class IPFSAWSS3 implements IIPFSAWSS3 {
createOrConnect(path:string, awsS3Bucket: string): Promise {
const IPFS = require('ipfs');
const ipfs = IPFS.create();
};
create.spec.ts - using jest to transpile and run.
import IPFSAWSS3, { IIPFSAWSS3 } from './../src/index';
test("can create", async () => {
const ipfsPath = '/blobchain/ipfs/secure';
const ipfsAwsS3Bucket = 'block-stream-ipfs-store';
const ipfs: Promise = new IPFSAWSS3().createOrConnect(ipfsPath,ipfsAwsS3Bucket);
const result = await ipfs;
expect(result).toBeFalsy();
})
The text was updated successfully, but these errors were encountered: