13 Feb 2025 |
sfroment | can mocha hide some unhandled promise rejection ? | 00:24:42 |
sfroment | I do the same test and in vite I have unhandled promise but moche I can just see console.log I added my self to check if the error was thre | 00:31:52 |
| @ahile:matrix.org joined the room. | 03:36:13 |
| @ahile:matrix.org left the room. | 03:36:23 |
Eloy | Hello! Minor question.
Is it possible to use helia node and connect to kubo node from a script right? I mean, I am able to do it from the browser, but I would like to do it from a script now, so want to be sure that it is possible.
If not, I guess I should use kubo-rpc-client | 05:14:35 |
Eloy | Just updated previous message with more information. Thanks a lot! 🙂 | 05:55:40 |
achingbrain | > from a script
Do you mean when running under node.js? | 06:08:23 |
Eloy | Thats correct yes. Using a script in typescript or js | 06:26:34 |
achingbrain | Yes, you can use Helia in node.js.
> ReferenceError: CustomEvent is not defined
What version of node are you running? | 06:35:50 |
Eloy | > What version of node are you running?
v18.20.5 | 06:40:37 |
achingbrain | CustomEvent was added in node 19 - you should try to use LTS node at least which is 22 right now | 06:42:52 |
Eloy | Thanks a lot! Let me try and update! | 06:43:28 |
Eloy | Worked! At least establishing the connections with my kubo node using websockets. | 07:25:33 |
Eloy | Thanks again! 🙂 | 07:25:50 |
achingbrain | No problem. You can use TCP from node.js as well, it’s faster than WebSockets. | 07:36:23 |
achingbrain | I believe mocha adds a handler for unhandled rejections to detect internal errors - if the error is not from mocha it is re-emitted on the process object. | 07:37:18 |
Eloy | Ok and last one (I hope) to understand it. I am able to connect to my kubo node both tcp and websockets.
But I am trying to fetch the information from cid:
for await (const chunk of heliaNodeFilesystem.cat(CID.parse(cid), {
onProgress: (evt) => {
console.info('cat event', evt.type, evt.detail)
}
})) {
chunkReceived = false;
console.log("received chunk", chunk);
text += decoder.decode(chunk, { stream: true });
}
I can see that I am not receiving chunks. Why could this be? I guess the node has no route to the CID to retrieve it? Should I need to do any other thing to get the CID?
This is the one if curious: QmR8F84sQoP2cRPymXiwLCtVBmHwwhGnd8fCw5W7eR7f5V
I am able to get it from my terminal using ipfs cat but not from the script.
Thanks a lot again!!:) | 08:08:56 |
achingbrain | It works for me?
import { createHelia } from 'helia'
import { unixfs } from '@helia/unixfs'
import { CID } from 'multiformats/cid'
const cid = CID.parse('QmR8F84sQoP2cRPymXiwLCtVBmHwwhGnd8fCw5W7eR7f5V')
const helia = await createHelia()
const fs = unixfs(helia)
for await (const chunk of fs.cat(cid, {
onProgress: (evt) => {
console.info('progress', evt)
}
})) {
console.info('chunk', chunk)
}
Output: | 08:15:30 |
Eloy | Yes, working properly I got it. I was doing something wrong in the code to get it… not waiting enough, but getting it now. Thanks a lot! | 08:25:00 |
| alex_peeranha joined the room. | 14:53:44 |
14 Feb 2025 |
Hayden | I would like to test replication between two OrbitDB peers where there is a dropout in the libp2p connection. What is the easiest way to replicate this? Can I simply call libp2p.hangUp on one of the peers? | 11:55:11 |
zumerine6840 | Redacted or Malformed Event | 11:57:34 |
zumerine6840 | Redacted or Malformed Event | 11:58:50 |
achingbrain | That will close any open connections, though there’s no guarantee they won’t be reopened - is that enough? | 14:07:24 |
Hayden | If I hangUp, there seems to be no disruption to the sync so either that's a good thing or I'm not replicating the dropout properly.
I guess the use case is a major dropout, say the connection is disconnected between two peers because the cable is unplugged. | 16:55:08 |
Hayden | I'm also assuming hangUp has a "grace" period whereby the stream is allowed to empty before libp2p tries to close it. Maybe I need to pass "hangUp" a signal param to force hangUp to hang up" more abruptly? | 17:03:18 |
achingbrain | Yes, it’ll close all connections gracefully which will let all data finish sending. If closing gracefully fails it’ll abort the connections which drops the data on the floor. You can either do this manually (by calling .abort on the connection) or by passing an AbortSignal with a very short timeout. | 17:13:35 |
Hayden | > by passing an AbortSignal with a very short timeout.
Okay trying this. | 17:15:01 |
| kabostebeztak joined the room. | 21:41:05 |
15 Feb 2025 |
| biglep (OOO until 2025-02-24) changed their display name from biglep to biglep (OOO until 2025-02-24). | 03:16:09 |