Skip to content

Commit a2f8b6a

Browse files
authored
test: fix undici 8.7.0 compatibility (#3345)
* test: fix undici 8.7.0 compatibility * chore: add 30m timeout to test jobs
1 parent ef586e1 commit a2f8b6a

3 files changed

Lines changed: 21 additions & 0 deletions

File tree

.github/workflows/tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ jobs:
6060
test-pack:
6161
name: Test Pack
6262
runs-on: ubuntu-latest
63+
timeout-minutes: 30
6364
steps:
6465
- name: Checkout Repository
6566
uses: actions/checkout@v7
@@ -111,6 +112,7 @@ jobs:
111112
node: 26.x
112113
name: ${{ matrix.os }} - ${{ matrix.python }} - ${{ matrix.node }}
113114
runs-on: ${{ matrix.os }}
115+
timeout-minutes: 30
114116
env:
115117
WASI_VERSION: '25'
116118
WASI_VERSION_FULL: '25.0'

.github/workflows/visual-studio.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jobs:
2424
- os: windows-11-arm
2525
msvs-version: 2022 # Fix this when Visual Studio 2025 is released
2626
runs-on: ${{ matrix.os }}
27+
timeout-minutes: 30
2728
steps:
2829
- name: Checkout Repository
2930
uses: actions/checkout@v7

test/test-download.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,24 @@ describe('download', function () {
7777

7878
let proxyUsed = false
7979
const pserver = http.createServer()
80+
// undici tunnels https requests through the proxy with CONNECT, but forwards
81+
// plain http requests to the proxy in absolute-form. Handle both so the test
82+
// works regardless of which path undici picks.
83+
pserver.on('request', (creq, cres) => {
84+
proxyUsed = true
85+
const target = new URL(creq.url)
86+
const proxyReq = http.request({
87+
host: target.hostname,
88+
port: target.port,
89+
path: target.pathname + target.search,
90+
method: creq.method,
91+
headers: creq.headers
92+
}, (proxyRes) => {
93+
cres.writeHead(proxyRes.statusCode, proxyRes.headers)
94+
proxyRes.pipe(cres)
95+
})
96+
creq.pipe(proxyReq)
97+
})
8098
pserver.on('connect', (req, clientSocket, head) => {
8199
proxyUsed = true
82100
const [targetHost, targetPort] = req.url.split(':')

0 commit comments

Comments
 (0)