braidfs 0.0.129 → 0.0.130
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +54 -2
- package/package.json +3 -3
package/index.js
CHANGED
|
@@ -30,6 +30,9 @@ braid_text.db_folder = `${braidfs_config_dir}/braid-text-db`
|
|
|
30
30
|
var trash = `${braidfs_config_dir}/trash`
|
|
31
31
|
var temp_folder = `${braidfs_config_dir}/temp`
|
|
32
32
|
|
|
33
|
+
// DEBUGGING HACK ID: L04LPFHQ1M -- INVESTIGATING DISCONNECTS
|
|
34
|
+
var investigating_disconnects_log = `${braidfs_config_dir}/investigating_disconnects.log`
|
|
35
|
+
|
|
33
36
|
var config = null,
|
|
34
37
|
watcher_misses = 0,
|
|
35
38
|
reconnect_rate_limiter = new ReconnectRateLimiter(() =>
|
|
@@ -70,6 +73,13 @@ require('fs').mkdirSync(sync_base_meta, { recursive: true })
|
|
|
70
73
|
require('fs').mkdirSync(trash, { recursive: true })
|
|
71
74
|
require('fs').mkdirSync(temp_folder, { recursive: true })
|
|
72
75
|
|
|
76
|
+
// DEBUGGING HACK ID: L04LPFHQ1M -- INVESTIGATING DISCONNECTS
|
|
77
|
+
require('fs').appendFileSync(investigating_disconnects_log, `${Date.now()} -- braidfs starting\n`)
|
|
78
|
+
function do_investigating_disconnects_log(url, message) {
|
|
79
|
+
if (url.match(/^https:\/\/(dt\.)?braid\.org\/hello$/))
|
|
80
|
+
require('fs').appendFileSync(investigating_disconnects_log, `${Date.now()}:${url} -- ${message}\n`)
|
|
81
|
+
}
|
|
82
|
+
|
|
73
83
|
// Add instructions for how to run in the background on this OS
|
|
74
84
|
var to_run_in_background = process.platform === 'darwin' ? `
|
|
75
85
|
To run daemon in background:
|
|
@@ -389,6 +399,9 @@ function unsync_url(url) {
|
|
|
389
399
|
|
|
390
400
|
console.log(`unsync_url: ${url}`)
|
|
391
401
|
|
|
402
|
+
// DEBUGGING HACK ID: L04LPFHQ1M -- INVESTIGATING DISCONNECTS
|
|
403
|
+
do_investigating_disconnects_log(url, `unsync_url: ${url}`)
|
|
404
|
+
|
|
392
405
|
delete sync_url.cache[url]
|
|
393
406
|
sync_url.chain = sync_url.chain.then(unsync_url.cache[url])
|
|
394
407
|
delete unsync_url.cache[url]
|
|
@@ -407,6 +420,9 @@ async function sync_url(url) {
|
|
|
407
420
|
fullpath = `${sync_base}/${path}`,
|
|
408
421
|
meta_path = `${sync_base_meta}/${braid_text.encode_filename(url)}`
|
|
409
422
|
|
|
423
|
+
// DEBUGGING HACK ID: L04LPFHQ1M -- INVESTIGATING DISCONNECTS
|
|
424
|
+
do_investigating_disconnects_log(url, `sync_url`)
|
|
425
|
+
|
|
410
426
|
if (!sync_url.cache) sync_url.cache = {}
|
|
411
427
|
if (!sync_url.chain) sync_url.chain = Promise.resolve()
|
|
412
428
|
if (!sync_url.cache[path]) {
|
|
@@ -764,6 +780,9 @@ async function sync_url(url) {
|
|
|
764
780
|
file_loop_pump()
|
|
765
781
|
}
|
|
766
782
|
|
|
783
|
+
// DEBUGGING HACK ID: L04LPFHQ1M -- INVESTIGATING DISCONNECTS
|
|
784
|
+
do_investigating_disconnects_log(url, 'before within_fiber')
|
|
785
|
+
|
|
767
786
|
await within_fiber(fullpath, async () => {
|
|
768
787
|
if (freed) return
|
|
769
788
|
var fullpath = await get_fullpath()
|
|
@@ -822,6 +841,9 @@ async function sync_url(url) {
|
|
|
822
841
|
})
|
|
823
842
|
if (freed) return
|
|
824
843
|
|
|
844
|
+
// DEBUGGING HACK ID: L04LPFHQ1M -- INVESTIGATING DISCONNECTS
|
|
845
|
+
do_investigating_disconnects_log(url, 'after within_fiber')
|
|
846
|
+
|
|
825
847
|
await file_loop_pump()
|
|
826
848
|
async function file_loop_pump() {
|
|
827
849
|
if (freed) return
|
|
@@ -961,12 +983,21 @@ async function sync_url(url) {
|
|
|
961
983
|
file_loop_pump_lock--
|
|
962
984
|
}
|
|
963
985
|
|
|
986
|
+
// DEBUGGING HACK ID: L04LPFHQ1M -- INVESTIGATING DISCONNECTS
|
|
987
|
+
do_investigating_disconnects_log(url, 'after file_loop_pump')
|
|
988
|
+
|
|
964
989
|
function start_sync() {
|
|
990
|
+
// DEBUGGING HACK ID: L04LPFHQ1M -- INVESTIGATING DISCONNECTS
|
|
991
|
+
do_investigating_disconnects_log(url, 'start_sync')
|
|
992
|
+
|
|
965
993
|
var closed = false
|
|
966
994
|
var ac = new AbortController()
|
|
967
995
|
aborts.add(ac)
|
|
968
996
|
|
|
969
997
|
self.disconnect = async () => {
|
|
998
|
+
// DEBUGGING HACK ID: L04LPFHQ1M -- INVESTIGATING DISCONNECTS
|
|
999
|
+
do_investigating_disconnects_log(url, 'self.disconnect')
|
|
1000
|
+
|
|
970
1001
|
if (closed) return
|
|
971
1002
|
closed = true
|
|
972
1003
|
reconnect_rate_limiter.on_diss(url)
|
|
@@ -987,32 +1018,53 @@ async function sync_url(url) {
|
|
|
987
1018
|
|
|
988
1019
|
// Use braid_text.sync for bidirectional sync with the remote URL
|
|
989
1020
|
if (is_external_link) braid_text.sync(url, new URL(url), {
|
|
1021
|
+
|
|
1022
|
+
// DEBUGGING HACK ID: L04LPFHQ1M -- INVESTIGATING DISCONNECTS
|
|
1023
|
+
do_investigating_disconnects_log_L04LPFHQ1M: do_investigating_disconnects_log,
|
|
1024
|
+
|
|
990
1025
|
fork_point_hint: old_meta_fork_point,
|
|
991
1026
|
signal: ac.signal,
|
|
992
1027
|
headers: {
|
|
993
1028
|
'Content-Type': 'text/plain',
|
|
994
1029
|
...(x => x && { Cookie: x })(config.cookies?.[new URL(url).hostname])
|
|
995
1030
|
},
|
|
996
|
-
on_pre_connect: () =>
|
|
1031
|
+
on_pre_connect: () => {
|
|
1032
|
+
// DEBUGGING HACK ID: L04LPFHQ1M -- INVESTIGATING DISCONNECTS
|
|
1033
|
+
do_investigating_disconnects_log(url, `sync.on_pre_connect`)
|
|
1034
|
+
|
|
1035
|
+
return reconnect_rate_limiter.get_turn(url)
|
|
1036
|
+
},
|
|
997
1037
|
on_res: res => {
|
|
1038
|
+
// DEBUGGING HACK ID: L04LPFHQ1M -- INVESTIGATING DISCONNECTS
|
|
1039
|
+
do_investigating_disconnects_log(url, `sync.on_res status:${res?.status}`)
|
|
1040
|
+
|
|
998
1041
|
if (freed) return
|
|
999
1042
|
reconnect_rate_limiter.on_conn(url)
|
|
1000
1043
|
self.file_read_only = res.headers.get('editable') === 'false'
|
|
1001
1044
|
console.log(`connected to ${url}${self.file_read_only ? ' (readonly)' : ''}`)
|
|
1002
1045
|
},
|
|
1003
1046
|
on_unauthorized: async () => {
|
|
1047
|
+
// DEBUGGING HACK ID: L04LPFHQ1M -- INVESTIGATING DISCONNECTS
|
|
1048
|
+
do_investigating_disconnects_log(url, `sync.on_unauthorized`)
|
|
1049
|
+
|
|
1004
1050
|
console.log(`access denied: reverting local edits`)
|
|
1005
1051
|
unsync_url(url)
|
|
1006
1052
|
//await sync_url.chain
|
|
1007
1053
|
sync_url(url)
|
|
1008
1054
|
},
|
|
1009
1055
|
on_disconnect: () => {
|
|
1010
|
-
|
|
1056
|
+
// DEBUGGING HACK ID: L04LPFHQ1M -- INVESTIGATING DISCONNECTS
|
|
1057
|
+
do_investigating_disconnects_log(url, `sync.on_disconnect`)
|
|
1058
|
+
|
|
1059
|
+
return reconnect_rate_limiter.on_diss(url)
|
|
1011
1060
|
}
|
|
1012
1061
|
})
|
|
1013
1062
|
}
|
|
1014
1063
|
|
|
1015
1064
|
self.reconnect = () => {
|
|
1065
|
+
// DEBUGGING HACK ID: L04LPFHQ1M -- INVESTIGATING DISCONNECTS
|
|
1066
|
+
do_investigating_disconnects_log(url, `reconnect`)
|
|
1067
|
+
|
|
1016
1068
|
for (var a of aborts) a.abort()
|
|
1017
1069
|
aborts.clear()
|
|
1018
1070
|
start_sync()
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "braidfs",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.130",
|
|
4
4
|
"description": "braid technology synchronizing files and webpages",
|
|
5
5
|
"author": "Braid Working Group",
|
|
6
6
|
"repository": "braid-org/braidfs",
|
|
7
7
|
"homepage": "https://braid.org",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"braid-http": "~1.3.
|
|
10
|
-
"braid-text": "~0.2.
|
|
9
|
+
"braid-http": "~1.3.85",
|
|
10
|
+
"braid-text": "~0.2.97",
|
|
11
11
|
"braid-blob": "~0.0.30",
|
|
12
12
|
"chokidar": "^4.0.3"
|
|
13
13
|
},
|