pear-runtime-updater 3.0.10 → 3.0.11

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.
Files changed (2) hide show
  1. package/index.js +10 -3
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -34,6 +34,9 @@ module.exports = class PearRuntimeUpdater extends ReadyResource {
34
34
  this.link = link.serialize({ drive: { fork: this.fork, length: this.length, key: this.key } })
35
35
  this.drive = new Hyperdrive(this.store, this.key)
36
36
 
37
+ this._start = Date.now()
38
+ this._bootGracePeriod = 60000
39
+
37
40
  this.next = null
38
41
  this.checkout = null
39
42
  this.prefetched = false
@@ -64,9 +67,13 @@ module.exports = class PearRuntimeUpdater extends ReadyResource {
64
67
  this._debouncedUpdate().catch((err) => this.emit('error', err))
65
68
  this.drive.core.on('append', () => {
66
69
  if (this._scheduledUpdate !== null) clearTimeout(this._scheduledUpdate) // cancel old pending updates before scheduling new one
67
- this._scheduledUpdate = setTimeout(() => {
68
- this._debouncedUpdate().catch((err) => this.emit('error', err))
69
- }, this._delay)
70
+ const recentBoot = Date.now() - this._start <= this._bootGracePeriod
71
+ this._scheduledUpdate = setTimeout(
72
+ () => {
73
+ this._debouncedUpdate().catch((err) => this.emit('error', err))
74
+ },
75
+ recentBoot ? 0 : this._delay
76
+ )
70
77
  this.emit('update-scheduled', this._delay)
71
78
  })
72
79
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pear-runtime-updater",
3
- "version": "3.0.10",
3
+ "version": "3.0.11",
4
4
  "description": "Listens for OTA Pear App updates",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Holepunch Inc",