Created
March 15, 2019 17:58
-
-
Save joehand/ad9d3a3dc7f7d7ab611307d396025fbe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var hyperdrive = require('hyperdrive') | |
var pump = require('pump') | |
var fs = require('fs') | |
var storage = require('dat-storage') | |
var source = hyperdrive('./source') | |
source.ready(() => { | |
var dest = hyperdrive(storage('./dest'), source.key, { | |
latest: true, sparse: false | |
}) | |
dest.on('syncing', () => { | |
console.log('dest syncing') | |
console.log(' dest version:', dest.version) | |
console.log(' source version:', source.version) | |
}) | |
dest.on('sync', () => { | |
console.log('dest sync, version:', dest.version) | |
}) | |
setInterval(() => { | |
source.readFile('hi.txt', 'utf8', (err,data) => { | |
if (!data) data = '' | |
source.writeFile('hi.txt', data + new Date() + '\n') | |
}) | |
}, 1000) | |
var stream = dest.replicate({live: true}) | |
stream.pipe(source.replicate()).pipe(stream) | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "latest-cpu", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"keywords": [], | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"dat-storage": "^1.1.1", | |
"hyperdrive": "^9.14.2", | |
"pump": "^3.0.0" | |
} | |
} |
Interesting enough, when I switched to the v10 branch and changed 'syncing'
to 'update'
, things look okay:
dest syncing
dest version: 290
source version: 290
dest syncing
dest version: 291
source version: 291
dest syncing
dest version: 292
source version: 292
dest syncing
dest version: 293
source version: 293
dest syncing
dest version: 294
source version: 294
dest syncing
dest version: 295
source version: 295
dest syncing
dest version: 296
source version: 296
dest syncing
dest version: 297
source version: 297
dest syncing
dest version: 298
source version: 298
dest syncing
dest version: 299
source version: 299
It might be great to include this in the general hyperdrive tests
Hmmm @jedahan I still saw the same bug with node v10.
@allain, ya seems this is happening whenever latest: true
regardless of storage.
_fetchVersion callback is called multiple times https://github.com/mafintosh/hyperdrive/blob/acf7d5416d4a189170a13073012176b5c5c4c0cd/index.js#L184
That should help narrow down the bug.
It happens on node v9, v10, and v11 for me.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If it helps the issue persists with random-access-memory as the storage backend.