-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #302 from earthstar-project/sync-test-net-widen
Fix attachments for existing docs not being synced, prevent syncing hangs, add timeouts
- Loading branch information
Showing
9 changed files
with
530 additions
and
45 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
|
||
/** A timeout which can be 'bumped' manually, restarting the timer. */ | ||
export class BumpingTimeout { | ||
private timeout: number; | ||
private cb: () => void; | ||
private ms: number; | ||
private closed = false; | ||
|
||
constructor(cb: () => void, ms: number) { | ||
this.cb = cb; | ||
this.ms = ms; | ||
this.timeout = setTimeout(cb, ms); | ||
} | ||
|
||
bump() { | ||
if (this.closed) { | ||
return; | ||
} | ||
|
||
clearTimeout(this.timeout); | ||
this.timeout = setTimeout(this.cb, this.ms); | ||
} | ||
|
||
close() { | ||
this.closed = true; | ||
|
||
clearTimeout(this.timeout); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Research indicates 10 seconds is the limit for holding someone's attention without any kind of feedback. | ||
/** The maximum number of milliseconds to wait for some kind of communication from the other peer. */ | ||
export const TIMEOUT_MS = 10000; |
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.