Skip to content

Commit

Permalink
dont close localwriters either during removal, let gc do it (#175)
Browse files Browse the repository at this point in the history
  • Loading branch information
mafintosh authored Aug 23, 2024
1 parent 02fc625 commit 9b5dfb9
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 10 deletions.
6 changes: 0 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ module.exports = class Autobase extends ReadyResource {
this._addCheckpoints = false
this._firstCheckpoint = true
this._hasPendingCheckpoint = false
this._pendingLocalRemoval = false
this._completeRemovalAt = null
this._systemPointer = 0
this._maybeStaticFastForward = false // writer bumps this
Expand Down Expand Up @@ -1074,7 +1073,6 @@ module.exports = class Autobase extends ReadyResource {
} else if (!localIndexer && wasActiveIndexer) {
this._unsetLocalIndexer()
this._clearLocalIndexer()
if (this._pendingLocalRemoval) this._unsetLocalWriter()
}

this._updateLinearizer(indexers, sys.heads)
Expand Down Expand Up @@ -1144,7 +1142,6 @@ module.exports = class Autobase extends ReadyResource {
if (this.localWriter.isActiveIndexer) this._clearLocalIndexer()

this.localWriter = null
this._pendingLocalRemoval = false

this.emit('unwritable')
}
Expand Down Expand Up @@ -1296,8 +1293,6 @@ module.exports = class Autobase extends ReadyResource {

if (this.opened) await this._updateBootRecordHeads(this.system.heads)

if (this._pendingLocalRemoval && !this.localWriter.isActiveIndexer) this._unsetLocalWriter()

if (this._interrupting) return

const flushed = (await this._flushIndexes()) ? this.system.core.getBackingCore().flushedLength : this._systemPointer
Expand Down Expand Up @@ -1942,7 +1937,6 @@ module.exports = class Autobase extends ReadyResource {
await this.system.remove(key)

if (b4a.equals(key, this.local.key)) {
this._pendingLocalRemoval = true
if (this.isIndexer) this._unsetLocalIndexer()
}

Expand Down
5 changes: 1 addition & 4 deletions test/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -1366,7 +1366,7 @@ test('basic - indexer removes themselves', async t => {

t.not(a.view.length, length) // can still read

await confirm([a, b, c])
await confirm([b, c, a]) // a has to come last cause otherwise confirm add it to the maj peers

t.not(a.view.indexedLength, indexedLength) // b,c can still index

Expand Down Expand Up @@ -1477,7 +1477,6 @@ test('basic - add new indexer after removing', async t => {
await confirm([a, b])

t.is(b.writable, false)
t.is(b.localWriter, null)

t.is(a.linearizer.indexers.length, 1)
t.is(b.linearizer.indexers.length, 1)
Expand All @@ -1495,9 +1494,7 @@ test('basic - add new indexer after removing', async t => {

await c.append('c1')

b.debug = true
t.is(b.writable, false)
t.is(b.localWriter, null)

await confirm([a, b, c])
await replicateAndSync([a, b, c])
Expand Down

0 comments on commit 9b5dfb9

Please sign in to comment.