braid-text 0.2.106 → 0.2.107
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 +39 -36
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -209,46 +209,49 @@ function create_braid_text() {
|
|
|
209
209
|
}
|
|
210
210
|
|
|
211
211
|
async function send_pump() {
|
|
212
|
-
if (signal.aborted) return
|
|
213
212
|
send_pump_lock++
|
|
214
213
|
if (send_pump_lock > 1) return
|
|
215
|
-
|
|
216
|
-
if (!q.length) {
|
|
217
|
-
// Extend frontier based on in-flight updates
|
|
218
|
-
var frontier = resource.meta.fork_point || []
|
|
219
|
-
for (var u of in_flight.values())
|
|
220
|
-
frontier = extend_frontier(frontier, u.version, u.parents)
|
|
221
|
-
|
|
222
|
-
var temp_ac = new AbortController()
|
|
223
|
-
temp_acs.add(temp_ac)
|
|
224
|
-
var get_options = {
|
|
225
|
-
signal: temp_ac.signal,
|
|
226
|
-
parents: frontier,
|
|
227
|
-
merge_type: 'dt',
|
|
228
|
-
peer: options.peer,
|
|
229
|
-
subscribe: u => u.version?.length && q.push(u)
|
|
230
|
-
}
|
|
231
|
-
await braid_text.get(a, get_options)
|
|
232
|
-
await get_options.my_subscribe_chain
|
|
214
|
+
try {
|
|
233
215
|
if (signal.aborted) return
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
216
|
+
if (in_flight.size >= max_in_flight) return
|
|
217
|
+
if (!q.length) {
|
|
218
|
+
// Extend frontier based on in-flight updates
|
|
219
|
+
var frontier = resource.meta.fork_point || []
|
|
220
|
+
for (var u of in_flight.values())
|
|
221
|
+
frontier = extend_frontier(frontier, u.version, u.parents)
|
|
222
|
+
|
|
223
|
+
var temp_ac = new AbortController()
|
|
224
|
+
temp_acs.add(temp_ac)
|
|
225
|
+
var get_options = {
|
|
226
|
+
signal: temp_ac.signal,
|
|
227
|
+
parents: frontier,
|
|
228
|
+
merge_type: 'dt',
|
|
229
|
+
peer: options.peer,
|
|
230
|
+
subscribe: u => u.version?.length && q.push(u)
|
|
231
|
+
}
|
|
232
|
+
await braid_text.get(a, get_options)
|
|
233
|
+
await get_options.my_subscribe_chain
|
|
234
|
+
if (signal.aborted) return
|
|
235
|
+
temp_ac.abort()
|
|
236
|
+
temp_acs.delete(temp_ac)
|
|
237
|
+
}
|
|
238
|
+
while (q.length && in_flight.size < max_in_flight) {
|
|
239
|
+
let u = q.shift()
|
|
240
|
+
if (!u.version?.length) continue
|
|
241
|
+
in_flight.set(u.version[0], u)
|
|
242
|
+
void (async () => {
|
|
243
|
+
try {
|
|
244
|
+
await send_out(u)
|
|
245
|
+
if (signal.aborted) return
|
|
246
|
+
in_flight.delete(u.version[0])
|
|
247
|
+
setTimeout(send_pump, 0)
|
|
248
|
+
} catch (e) { handle_error(e) }
|
|
249
|
+
})()
|
|
250
|
+
}
|
|
251
|
+
} finally {
|
|
252
|
+
if (send_pump_lock > 1) setTimeout(send_pump, 0)
|
|
253
|
+
send_pump_lock = 0
|
|
249
254
|
}
|
|
250
|
-
if (send_pump_lock > 1) setTimeout(send_pump, 0)
|
|
251
|
-
send_pump_lock = 0
|
|
252
255
|
}
|
|
253
256
|
|
|
254
257
|
var a_ops = {
|