@nxtedition/lib 21.0.15 → 21.0.16
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 +3 -20
- package/package.json +1 -1
package/http.js
CHANGED
|
@@ -52,20 +52,7 @@ export async function request(ctx, next) {
|
|
|
52
52
|
ctx.signal = ac.signal
|
|
53
53
|
ctx.method = req.method
|
|
54
54
|
ctx.query = ctx.url.search.length > 1 ? querystring.parse(ctx.url.search.slice(1)) : {}
|
|
55
|
-
ctx.logger =
|
|
56
|
-
req.log =
|
|
57
|
-
res.log =
|
|
58
|
-
logger.child({
|
|
59
|
-
req: {
|
|
60
|
-
id: req.id,
|
|
61
|
-
url: req.url,
|
|
62
|
-
scheme: ctx.url.protocol,
|
|
63
|
-
host: ctx.url.hostname,
|
|
64
|
-
port: ctx.url.port,
|
|
65
|
-
path: ctx.url.pathname,
|
|
66
|
-
query: ctx.query,
|
|
67
|
-
},
|
|
68
|
-
})
|
|
55
|
+
ctx.logger = req.log = res.log = logger.child({ req: { id: req.id, url: req.url } })
|
|
69
56
|
|
|
70
57
|
if (req.method === 'GET' || req.method === 'HEAD') {
|
|
71
58
|
req.resume() // Dump the body if there is one.
|
|
@@ -83,14 +70,10 @@ export async function request(ctx, next) {
|
|
|
83
70
|
await Promise.all([
|
|
84
71
|
next(),
|
|
85
72
|
new Promise((resolve, reject) => {
|
|
86
|
-
req.on('timeout', onRequestTimeout).on('error',
|
|
87
|
-
reject(err)
|
|
88
|
-
})
|
|
73
|
+
req.on('timeout', onRequestTimeout).on('error', reject)
|
|
89
74
|
res
|
|
90
75
|
.on('timeout', onResponseTimeout)
|
|
91
|
-
.on('error',
|
|
92
|
-
reject(err)
|
|
93
|
-
})
|
|
76
|
+
.on('error', reject)
|
|
94
77
|
// TODO (fix): Use 'end' once we can trust that
|
|
95
78
|
// 'end' or 'error' will always be emitted.
|
|
96
79
|
.on('close', function () {
|