orbitdb / orbitdb

Peer-to-Peer Databases for the Decentralized Web

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Recover from [AggregateError: All promises were rejected] Error: Want for xyz aborted

koh-osug opened this issue · comments

One of my peers is crashing. When this happens the sending peer is crashing also. I assume because it cannot sync with the crashed other peer anymore. I get:

node:internal/process/promises:289
triggerUncaughtException(err, true /* fromPromise */);
^

[AggregateError: All promises were rejected] {
[errors]: [
Error: Want for bafyreifolbhkz5za75dw5b7tgq45vlc23fwsk3ujxlc6qhv4aft3tuzbhy aborted
at EventTarget. (file:///home/test/orbitdb/src/node_modules/@helia/block-brokers/node_modules/ipfs-bitswap/dist/src/notifications.js:56:24)
at [nodejs.internal.kHybridDispatch] (node:internal/event_target:826:20)
at EventTarget.dispatchEvent (node:internal/event_target:761:26)
at abortSignal (node:internal/abort_controller:371:10)
at AbortController.abort (node:internal/abort_controller:393:5)
at EventTarget.onAbort (file:///home/test/orbitdb/src/node_modules/any-signal/dist/src/index.js:8:20)
at [nodejs.internal.kHybridDispatch] (node:internal/event_target:826:20)
at EventTarget.dispatchEvent (node:internal/event_target:761:26)
at abortSignal (node:internal/abort_controller:371:10)
at AbortController.abort (node:internal/abort_controller:393:5)
]
}

Then the peer is also crashing. The error causing this in the other peer is:

/home/test/orbitdb/src/node_modules/abstract-level/abstract-level.js:133
callback(new ModuleError('Database is not open', {
^

ModuleError: Database is not open
at maybeOpened (/home/test/orbitdb/src/node_modules/abstract-level/abstract-level.js:133:18)
at /home/test/orbitdb/src/node_modules/abstract-level/abstract-level.js:160:13
at process.processTicksAndRejections (node:internal/process/task_queues:77:11) {
code: 'LEVEL_DATABASE_NOT_OPEN',
cause: [Error: IO error: lock orbitdb/1/orbitdb/zdpuAvRjoqLMMnyAdoXD2fZN4Hoz9Q1YXVsYX532ArbT2AwNB/log/_heads//LOCK: already held by process] {
code: 'LEVEL_LOCKED'
}
}

I don't know why the database is locked, maybe because of a previous crash, but I would not assume that a different peer is also crashing when this happens. The LOCK file is still in the directory, maybe it has to be removed?

Can I catch the error somehow in the other client and recover? I cannot find a stack trace from my code, this is all buried by the asynchronous magic of JavaScript.

Wrap the offending lines of code (I.e. the ones throwing the errors) in a try...catch block. The first error looks like a timeout error when retrieving a block from the other peer. The second error is the underlying LevelDB still being locked when you attempt to reopen it. You would need to explicitly close it before attempting to re-open it.

The culprit is likely a communication issue between IPFS peers (hence the ipfs bitswap error).

Wrap the offending lines of code (I.e. the ones throwing the errors) in a try...catch block.

That's the problem. At least in the first case this is not directly executed by my code and the stack trace does not show any of my code. It is happening asynchronously and my code is It seems that the complete DB, orbitdb, IPFS has crashed, i.e. I have to restart the whole program since I cannot add any try ... catch

Can you replicate the issue and post some kind of reproducible code snippet?

Closing with no response. Please feel free if you are able to provide some kind of working example.