@nxtedition/lib 21.5.8 → 21.5.10
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/app.js +1 -5
- package/couch.js +1 -0
- package/http.js +9 -0
- package/logger.js +3 -2
- package/package.json +1 -1
package/app.js
CHANGED
|
@@ -604,11 +604,7 @@ export function makeApp(appConfig, onTerminate) {
|
|
|
604
604
|
? rxjs.timer(0, 10e3).pipe(
|
|
605
605
|
rx.exhaustMap(async () => {
|
|
606
606
|
try {
|
|
607
|
-
|
|
608
|
-
await couch.up()
|
|
609
|
-
} catch {
|
|
610
|
-
await couch.info()
|
|
611
|
-
}
|
|
607
|
+
await couch.up()
|
|
612
608
|
return [
|
|
613
609
|
{
|
|
614
610
|
id: 'app:couch',
|
package/couch.js
CHANGED
|
@@ -118,6 +118,7 @@ export function makeCouch(opts) {
|
|
|
118
118
|
* @param {function} [options.retry=null] - The function to retry the request on error.
|
|
119
119
|
* @param {string} [options.since=null] - The sequence number to start from.
|
|
120
120
|
* @param {number} [options.highWaterMark=128 * 1024] - Buffering.
|
|
121
|
+
* @param {object} [options.selector=null] - The selector to filter changes.
|
|
121
122
|
* @yields {Array<{ id: string, seq?: string, doc?: Object, deleted?: boolean, changes: Array<{ rev: string }> }>}
|
|
122
123
|
*/
|
|
123
124
|
async function* changes({ client = defaultClient, signal = null, logger, ...options } = {}) {
|
package/http.js
CHANGED
|
@@ -115,6 +115,8 @@ export class Context {
|
|
|
115
115
|
|
|
116
116
|
function noop() {}
|
|
117
117
|
|
|
118
|
+
const pendingSet = (globalThis._nxt_lib_http_pending ??= new Set())
|
|
119
|
+
|
|
118
120
|
export async function request2(ctx, next) {
|
|
119
121
|
const { req, res, logger } = ctx
|
|
120
122
|
const startTime = performance.now()
|
|
@@ -122,6 +124,7 @@ export async function request2(ctx, next) {
|
|
|
122
124
|
req.on('error', noop)
|
|
123
125
|
res.on('error', noop)
|
|
124
126
|
|
|
127
|
+
pendingSet.add(ctx)
|
|
125
128
|
try {
|
|
126
129
|
if (req.method === 'GET' || req.method === 'HEAD') {
|
|
127
130
|
req.resume() // Dump the body if there is one.
|
|
@@ -221,6 +224,8 @@ export async function request2(ctx, next) {
|
|
|
221
224
|
}
|
|
222
225
|
}
|
|
223
226
|
} finally {
|
|
227
|
+
pendingSet.delete(ctx)
|
|
228
|
+
|
|
224
229
|
if (!res.writableEnded) {
|
|
225
230
|
res.destroy()
|
|
226
231
|
logger.debug('request destroyed')
|
|
@@ -235,6 +240,8 @@ export async function request(ctx, next) {
|
|
|
235
240
|
const ac = ctx.signal !== undefined ? null : new AbortController()
|
|
236
241
|
|
|
237
242
|
let reqLogger = logger
|
|
243
|
+
|
|
244
|
+
pendingSet.add(ctx)
|
|
238
245
|
try {
|
|
239
246
|
ctx.url = requestTarget(req)
|
|
240
247
|
if (!ctx.url) {
|
|
@@ -346,6 +353,8 @@ export async function request(ctx, next) {
|
|
|
346
353
|
}
|
|
347
354
|
}
|
|
348
355
|
} finally {
|
|
356
|
+
pendingSet.delete(ctx)
|
|
357
|
+
|
|
349
358
|
if (!res.writableEnded) {
|
|
350
359
|
res.destroy()
|
|
351
360
|
logger.debug('request destroyed')
|
package/logger.js
CHANGED
|
@@ -25,9 +25,10 @@ export function createLogger(
|
|
|
25
25
|
} else if (!isProduction) {
|
|
26
26
|
stream = pino.destination({ fd: process.stdout.fd ?? 1, sync: true })
|
|
27
27
|
} else if (!isMainThread) {
|
|
28
|
-
|
|
28
|
+
// TODO (perf): Async mode doesn't work super well in workers.
|
|
29
|
+
stream = pino.destination({ fd: 1, sync: true })
|
|
29
30
|
} else {
|
|
30
|
-
stream = pino.destination({ sync: false, minLength:
|
|
31
|
+
stream = pino.destination({ sync: false, minLength: 4 * 1024, maxWrite: 32 * 1024 })
|
|
31
32
|
|
|
32
33
|
let flushing = 0
|
|
33
34
|
setInterval(() => {
|