|
4 | 4 |
|
5 | 5 | /* global WebAssembly */
|
6 | 6 |
|
7 |
| -const assert = require('assert') |
8 |
| -const net = require('net') |
9 |
| -const http = require('http') |
10 |
| -const { pipeline } = require('stream') |
| 7 | +const assert = require('node:assert') |
| 8 | +const net = require('node:net') |
| 9 | +const http = require('node:http') |
| 10 | +const { pipeline } = require('node:stream') |
11 | 11 | const util = require('./core/util')
|
12 | 12 | const { channels } = require('./core/diagnostics')
|
13 | 13 | const timers = require('./timers')
|
@@ -84,7 +84,7 @@ const {
|
84 | 84 | /** @type {import('http2')} */
|
85 | 85 | let http2
|
86 | 86 | try {
|
87 |
| - http2 = require('http2') |
| 87 | + http2 = require('node:http2') |
88 | 88 | } catch {
|
89 | 89 | // @ts-ignore
|
90 | 90 | http2 = { constants: {} }
|
@@ -250,7 +250,7 @@ class Client extends DispatcherBase {
|
250 | 250 | })
|
251 | 251 | }
|
252 | 252 |
|
253 |
| - this[kInterceptors] = interceptors && interceptors.Client && Array.isArray(interceptors.Client) |
| 253 | + this[kInterceptors] = interceptors?.Client && Array.isArray(interceptors.Client) |
254 | 254 | ? interceptors.Client
|
255 | 255 | : [createRedirectInterceptor({ maxRedirections })]
|
256 | 256 | this[kUrl] = util.parseOrigin(url)
|
@@ -370,10 +370,10 @@ class Client extends DispatcherBase {
|
370 | 370 | // TODO: for H2 we need to gracefully flush the remaining enqueued
|
371 | 371 | // request and close each stream.
|
372 | 372 | return new Promise((resolve) => {
|
373 |
| - if (!this[kSize]) { |
374 |
| - resolve(null) |
375 |
| - } else { |
| 373 | + if (this[kSize]) { |
376 | 374 | this[kClosedResolve] = resolve
|
| 375 | + } else { |
| 376 | + resolve(null) |
377 | 377 | }
|
378 | 378 | })
|
379 | 379 | }
|
@@ -401,10 +401,10 @@ class Client extends DispatcherBase {
|
401 | 401 | this[kHTTP2SessionState] = null
|
402 | 402 | }
|
403 | 403 |
|
404 |
| - if (!this[kSocket]) { |
405 |
| - queueMicrotask(callback) |
406 |
| - } else { |
| 404 | + if (this[kSocket]) { |
407 | 405 | util.destroy(this[kSocket].on('close', callback), err)
|
| 406 | + } else { |
| 407 | + queueMicrotask(callback) |
408 | 408 | }
|
409 | 409 |
|
410 | 410 | resume(this)
|
@@ -479,15 +479,15 @@ async function lazyllhttp () {
|
479 | 479 |
|
480 | 480 | let mod
|
481 | 481 | try {
|
482 |
| - mod = await WebAssembly.compile(Buffer.from(require('./llhttp/llhttp_simd-wasm.js'), 'base64')) |
| 482 | + mod = await WebAssembly.compile(require('./llhttp/llhttp_simd-wasm.js')) |
483 | 483 | } catch (e) {
|
484 | 484 | /* istanbul ignore next */
|
485 | 485 |
|
486 | 486 | // We could check if the error was caused by the simd option not
|
487 | 487 | // being enabled, but the occurring of this other error
|
488 | 488 | // * https://github.com/emscripten-core/emscripten/issues/11495
|
489 | 489 | // got me to remove that check to avoid breaking Node 12.
|
490 |
| - mod = await WebAssembly.compile(Buffer.from(llhttpWasmData || require('./llhttp/llhttp-wasm.js'), 'base64')) |
| 490 | + mod = await WebAssembly.compile(llhttpWasmData || require('./llhttp/llhttp-wasm.js')) |
491 | 491 | }
|
492 | 492 |
|
493 | 493 | return await WebAssembly.instantiate(mod, {
|
|
0 commit comments