mirror of
https://github.com/orbitdb/orbitdb.git
synced 2025-03-30 15:08:28 +00:00
Merge 3735f6f51ffbb31815d5edda79a3ffb25e81cd51 into b5926cb972a5edf0d1dd0dd2cf3225f25a772b38
This commit is contained in:
commit
10c479ebb1
2486
package-lock.json
generated
2486
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
29
package.json
29
package.json
@ -20,6 +20,8 @@
|
||||
"dependencies": {
|
||||
"@ipld/dag-cbor": "^9.0.6",
|
||||
"@libp2p/crypto": "^5.0.5",
|
||||
"@libp2p/logger": "^5.1.8",
|
||||
"it-drain": "^3.0.7",
|
||||
"it-pipe": "^3.0.1",
|
||||
"level": "^8.0.0",
|
||||
"lru": "^3.1.0",
|
||||
@ -30,21 +32,33 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@chainsafe/libp2p-gossipsub": "^14.1.0",
|
||||
"@libp2p/circuit-relay-v2": "^3.1.0",
|
||||
"@chainsafe/libp2p-noise": "^16.0.1",
|
||||
"@chainsafe/libp2p-yamux": "^7.0.1",
|
||||
"@helia/block-brokers": "^4.0.4",
|
||||
"@libp2p/circuit-relay-v2": "^3.1.12",
|
||||
"@libp2p/identify": "^3.0.18",
|
||||
"@libp2p/webrtc": "^5.1.0",
|
||||
"@libp2p/websockets": "^9.1.5",
|
||||
"@multiformats/multiaddr": "^12.3.5",
|
||||
"@multiformats/multiaddr-matcher": "^1.6.0",
|
||||
"blockstore-core": "^5.0.2",
|
||||
"blockstore-level": "^2.0.1",
|
||||
"c8": "^8.0.1",
|
||||
"cross-env": "^7.0.3",
|
||||
"fs-extra": "^11.2.0",
|
||||
"glob": "^7.1.1",
|
||||
"helia": "^5.1.0",
|
||||
"it-all": "^3.0.4",
|
||||
"jsdoc": "^4.0.2",
|
||||
"libp2p": "^2.6.2",
|
||||
"mocha": "^10.2.0",
|
||||
"path-browserify": "^1.0.1",
|
||||
"playwright-test": "^14.1.6",
|
||||
"rimraf": "^5.0.5",
|
||||
"standard": "^17.1.0",
|
||||
"webpack": "^5.89.0",
|
||||
"webpack-cli": "^5.1.4"
|
||||
"webpack": "^5.98.0",
|
||||
"webpack-cli": "^5.1.4",
|
||||
"wherearewe": "^2.0.1"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "cross-env mocha --config test/.mocharc.json",
|
||||
@ -82,5 +96,12 @@
|
||||
"libp2p",
|
||||
"p2p",
|
||||
"peer-to-peer"
|
||||
]
|
||||
],
|
||||
"pnpm": {
|
||||
"onlyBuiltDependencies": [
|
||||
"@ipshipyard/node-datachannel",
|
||||
"classic-level",
|
||||
"esbuild"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
3
src/logger.js
Normal file
3
src/logger.js
Normal file
@ -0,0 +1,3 @@
|
||||
import { logger } from '@libp2p/logger'
|
||||
|
||||
export const messageLog = logger('orbitdb')
|
@ -3,6 +3,7 @@ import PQueue from 'p-queue'
|
||||
import { EventEmitter } from 'events'
|
||||
import { TimeoutController } from 'timeout-abort-controller'
|
||||
import pathJoin from './utils/path-join.js'
|
||||
import { messageLog } from './logger.js'
|
||||
|
||||
const DefaultTimeout = 30000 // 30 seconds
|
||||
|
||||
@ -133,6 +134,7 @@ const Sync = async ({ ipfs, log, events, onSynced, start, timeout }) => {
|
||||
* @instance
|
||||
*/
|
||||
events = events || new EventEmitter()
|
||||
events.on('error', messageLog)
|
||||
|
||||
timeout = timeout || DefaultTimeout
|
||||
|
||||
|
@ -10,6 +10,7 @@ import LRUStorage from '../src/storage/lru.js'
|
||||
import IPFSBlockStorage from '../src/storage/ipfs-block.js'
|
||||
import ComposedStorage from '../src/storage/composed.js'
|
||||
import createHelia from './utils/create-helia.js'
|
||||
import { isBrowser } from 'wherearewe'
|
||||
|
||||
const keysPath = './testkeys'
|
||||
|
||||
@ -661,6 +662,69 @@ describe('Sync protocol', function () {
|
||||
})
|
||||
})
|
||||
|
||||
if (!isBrowser) {
|
||||
describe('Events - error listener', () => {
|
||||
let sync1, sync2
|
||||
let log1, log2
|
||||
|
||||
const timeoutTime = 1 // 1 millisecond
|
||||
const unhandledErrors = []
|
||||
const handleError = (err) => {
|
||||
unhandledErrors.push(err)
|
||||
}
|
||||
|
||||
before(async () => {
|
||||
[ipfs1, ipfs2] = await Promise.all([createHelia(), createHelia()])
|
||||
|
||||
peerId1 = ipfs1.libp2p.peerId
|
||||
peerId2 = ipfs2.libp2p.peerId
|
||||
|
||||
await connectPeers(ipfs1, ipfs2)
|
||||
|
||||
log1 = await Log(testIdentity1, { logId: 'synclog6' })
|
||||
log2 = await Log(testIdentity2, { logId: 'synclog6' })
|
||||
|
||||
process.on('unhandledRejection', handleError)
|
||||
})
|
||||
|
||||
after(async () => {
|
||||
if (sync1) {
|
||||
await sync1.stop()
|
||||
}
|
||||
if (sync2) {
|
||||
await sync2.stop()
|
||||
}
|
||||
if (log1) {
|
||||
await log1.close()
|
||||
}
|
||||
if (log2) {
|
||||
await log2.close()
|
||||
}
|
||||
|
||||
await ipfs1.stop()
|
||||
await ipfs2.stop()
|
||||
|
||||
process.off('unhandledRejection', handleError)
|
||||
})
|
||||
|
||||
it('does not crash when no listeners are attached to the `error` event on `Sync.events`', async () => {
|
||||
sync1 = await Sync({ ipfs: ipfs1, log: log1, timeout: timeoutTime })
|
||||
sync2 = await Sync({ ipfs: ipfs2, log: log2, start: false, timeout: timeoutTime })
|
||||
|
||||
await log1.append('hello1')
|
||||
|
||||
await sync2.start()
|
||||
|
||||
// Be sure to wait long enough for the timeout to cancel the operation with an error
|
||||
await new Promise(resolve => setTimeout(resolve, timeoutTime + 10))
|
||||
|
||||
// Test that no unhandled abort error has been thrown
|
||||
const err = unhandledErrors.find(e => e.code === 'ABORT_ERR')
|
||||
strictEqual(err, undefined)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
describe('Timeouts', () => {
|
||||
let sync1, sync2
|
||||
let log1, log2
|
||||
|
Loading…
x
Reference in New Issue
Block a user