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" | |
} | |
} |
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
It might be great to include this in the general hyperdrive tests