undici 4.9.1 → 4.9.2
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/lib/client.js +12 -14
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -408,8 +408,6 @@ class Client extends Dispatcher {
|
|
|
408
408
|
const constants = require('./llhttp/constants')
|
|
409
409
|
const EMPTY_BUF = Buffer.alloc(0)
|
|
410
410
|
|
|
411
|
-
let llhttpPromise
|
|
412
|
-
let llhttpInstance
|
|
413
411
|
async function lazyllhttp () {
|
|
414
412
|
const { resolve } = require('path')
|
|
415
413
|
const { readFile } = require('fs').promises
|
|
@@ -427,7 +425,7 @@ async function lazyllhttp () {
|
|
|
427
425
|
mod = await WebAssembly.compile(await readFile(resolve(__dirname, './llhttp/llhttp.wasm')))
|
|
428
426
|
}
|
|
429
427
|
|
|
430
|
-
|
|
428
|
+
return await WebAssembly.instantiate(mod, {
|
|
431
429
|
env: {
|
|
432
430
|
/* eslint-disable camelcase */
|
|
433
431
|
|
|
@@ -475,10 +473,14 @@ async function lazyllhttp () {
|
|
|
475
473
|
/* eslint-enable camelcase */
|
|
476
474
|
}
|
|
477
475
|
})
|
|
478
|
-
|
|
479
|
-
return llhttpInstance
|
|
480
476
|
}
|
|
481
477
|
|
|
478
|
+
let llhttpInstance = null
|
|
479
|
+
let llhttpPromise = lazyllhttp()
|
|
480
|
+
.catch(() => {
|
|
481
|
+
// TODO: Emit warning?
|
|
482
|
+
})
|
|
483
|
+
|
|
482
484
|
let currentParser = null
|
|
483
485
|
let currentBufferRef = null
|
|
484
486
|
let currentBufferSize = 0
|
|
@@ -1138,15 +1140,6 @@ async function connect (client) {
|
|
|
1138
1140
|
}
|
|
1139
1141
|
|
|
1140
1142
|
try {
|
|
1141
|
-
if (!llhttpInstance) {
|
|
1142
|
-
if (!llhttpPromise) {
|
|
1143
|
-
llhttpPromise = lazyllhttp()
|
|
1144
|
-
}
|
|
1145
|
-
await llhttpPromise
|
|
1146
|
-
assert(llhttpInstance)
|
|
1147
|
-
llhttpPromise = null
|
|
1148
|
-
}
|
|
1149
|
-
|
|
1150
1143
|
const socket = await new Promise((resolve, reject) => {
|
|
1151
1144
|
client[kConnector]({
|
|
1152
1145
|
host,
|
|
@@ -1163,6 +1156,11 @@ async function connect (client) {
|
|
|
1163
1156
|
})
|
|
1164
1157
|
})
|
|
1165
1158
|
|
|
1159
|
+
if (!llhttpInstance) {
|
|
1160
|
+
llhttpInstance = await llhttpPromise
|
|
1161
|
+
llhttpPromise = null
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1166
1164
|
client[kConnecting] = false
|
|
1167
1165
|
|
|
1168
1166
|
assert(socket)
|