| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent ea8930c commit 8e4046e
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,6 +3,7 @@ | |||
| 3 | 3 | /* global WebAssembly */ | |
| 4 | 4 | ||
| 5 | 5 | const assert = require('node:assert') | |
| 6 | + const { setTimeout: setTimeoutNative, clearTimeout: clearTimeoutNative } = require('node:timers') | ||
| 6 | 7 | const util = require('../core/util.js') | |
| 7 | 8 | const { channels } = require('../core/diagnostics.js') | |
| 8 | 9 | const timers = require('../util/timers.js') | |
@@ -1011,7 +1012,7 @@ function onSocketClose () { | |||
| 1011 | 1012 | ||
| 1012 | 1013 | function clearIdleSocketValidation (socket) { | |
| 1013 | 1014 | if (socket[kIdleSocketValidationTimeout]) { | |
| 1014 | - clearTimeout(socket[kIdleSocketValidationTimeout]) | ||
| 1015 | + clearTimeoutNative(socket[kIdleSocketValidationTimeout]) | ||
| 1015 | 1016 | socket[kIdleSocketValidationTimeout] = null | |
| 1016 | 1017 | } | |
| 1017 | 1018 | ||
@@ -1020,7 +1021,7 @@ function clearIdleSocketValidation (socket) { | |||
| 1020 | 1021 | ||
| 1021 | 1022 | function scheduleIdleSocketValidation (client, socket) { | |
| 1022 | 1023 | socket[kIdleSocketValidation] = 1 | |
| 1023 | - socket[kIdleSocketValidationTimeout] = setTimeout(() => { | ||
| 1024 | + socket[kIdleSocketValidationTimeout] = setTimeoutNative(() => { | ||
| 1024 | 1025 | socket[kIdleSocketValidationTimeout] = null | |
| 1025 | 1026 | socket[kIdleSocketValidation] = 2 | |
| 1026 | 1027 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,7 @@ | |||
| 1 | 1 | 'use strict' | |
| 2 | 2 | ||
| 3 | 3 | const assert = require('node:assert') | |
| 4 | + const { once } = require('node:events') | ||
| 4 | 5 | const { createServer } = require('node:http') | |
| 5 | 6 | const { after, test } = require('node:test') | |
| 6 | 7 | const { Client } = require('..') | |
@@ -37,6 +38,8 @@ test('should not reuse an idle socket with buffered unsolicited response bytes', | |||
| 37 | 38 | const response1 = await client.request({ path: '/request1', method: 'GET' }) | |
| 38 | 39 | assert.strictEqual(await readBody(response1.body), '/request1') | |
| 39 | 40 | ||
| 41 | + const disconnected = once(client, 'disconnect') | ||
| 42 | + | ||
| 40 | 43 | evilServerSocket.write( | |
| 41 | 44 | 'HTTP/1.1 200 OK\r\n' + | |
| 42 | 45 | 'Poison-Free-Socket: true\r\n' + | |
@@ -46,6 +49,8 @@ test('should not reuse an idle socket with buffered unsolicited response bytes', | |||
| 46 | 49 | '\r\n' | |
| 47 | 50 | ) | |
| 48 | 51 | ||
| 52 | + await disconnected | ||
| 53 | + | ||
| 49 | 54 | const response2 = await client.request({ path: '/request2', method: 'GET' }) | |
| 50 | 55 | assert.strictEqual(response2.headers['poison-free-socket'], undefined) | |
| 51 | 56 | assert.strictEqual(await readBody(response2.body), '/request2') | |
| Back | FazBrowse Home | New Git URL |
0 commit comments