@nxtedition/lib 25.1.2 → 25.1.4
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/http.js +1 -12
- package/package.json +1 -1
package/http.js
CHANGED
|
@@ -140,8 +140,6 @@ export class Context {
|
|
|
140
140
|
|
|
141
141
|
function noop() {}
|
|
142
142
|
|
|
143
|
-
const pendingSet = (globalThis._nxt_lib_http_pending ??= new Set())
|
|
144
|
-
|
|
145
143
|
export async function upgradeMiddleware(ctx, next) {
|
|
146
144
|
const { req, socket } = ctx
|
|
147
145
|
const startTime = performance.now()
|
|
@@ -158,7 +156,6 @@ export async function upgradeMiddleware(ctx, next) {
|
|
|
158
156
|
|
|
159
157
|
const isHealthcheck = req.url === '/healthcheck' || req.url === '/_up'
|
|
160
158
|
|
|
161
|
-
pendingSet.add(ctx)
|
|
162
159
|
try {
|
|
163
160
|
if (req.method === 'GET' || req.method === 'HEAD' || req.method === 'OPTIONS') {
|
|
164
161
|
req.resume() // Dump the body if there is one.
|
|
@@ -206,8 +203,6 @@ export async function upgradeMiddleware(ctx, next) {
|
|
|
206
203
|
}
|
|
207
204
|
socket.destroy(err)
|
|
208
205
|
} finally {
|
|
209
|
-
pendingSet.delete(ctx)
|
|
210
|
-
|
|
211
206
|
if (!socket.writableEnded && !socket.destroyed) {
|
|
212
207
|
socket.destroy()
|
|
213
208
|
ctx.logger?.warn('socket destroyed')
|
|
@@ -219,7 +214,6 @@ export async function requestMiddleware(ctx, next) {
|
|
|
219
214
|
const { req, res } = ctx
|
|
220
215
|
const startTime = performance.now()
|
|
221
216
|
|
|
222
|
-
pendingSet.add(ctx)
|
|
223
217
|
try {
|
|
224
218
|
if (req.method === 'GET' || req.method === 'HEAD' || req.method === 'OPTIONS') {
|
|
225
219
|
req.resume() // Dump the body if there is one.
|
|
@@ -328,8 +322,6 @@ export async function requestMiddleware(ctx, next) {
|
|
|
328
322
|
res.destroy(err)
|
|
329
323
|
}
|
|
330
324
|
} finally {
|
|
331
|
-
pendingSet.delete(ctx)
|
|
332
|
-
|
|
333
325
|
if (res.writableEnded || res.destroyed || res.stream?.destroyed) {
|
|
334
326
|
// Do nothing..
|
|
335
327
|
} else {
|
|
@@ -636,7 +628,6 @@ export async function request(ctx, next) {
|
|
|
636
628
|
|
|
637
629
|
let reqLogger = logger
|
|
638
630
|
|
|
639
|
-
pendingSet.add(ctx)
|
|
640
631
|
try {
|
|
641
632
|
ctx.url = requestTarget(req)
|
|
642
633
|
if (!ctx.url) {
|
|
@@ -746,8 +737,6 @@ export async function request(ctx, next) {
|
|
|
746
737
|
}
|
|
747
738
|
}
|
|
748
739
|
} finally {
|
|
749
|
-
pendingSet.delete(ctx)
|
|
750
|
-
|
|
751
740
|
if (!res.writableEnded) {
|
|
752
741
|
res.destroy()
|
|
753
742
|
logger.debug('request destroyed')
|
|
@@ -954,7 +943,7 @@ export async function retry(fn, options) {
|
|
|
954
943
|
* @param {Array} middleware
|
|
955
944
|
* @return {Function}
|
|
956
945
|
*/
|
|
957
|
-
const composeSlim = (middleware) =>
|
|
946
|
+
const composeSlim = (middleware) => (ctx, next) => {
|
|
958
947
|
const dispatch = (i) => () => {
|
|
959
948
|
const fn = i === middleware.length ? next : middleware[i]
|
|
960
949
|
return fn ? fn(ctx, dispatch(i + 1)) : undefined
|