Skip to content

Commit 753db48

Browse files
committed
FIXUP
1 parent ed6afda commit 753db48

11 files changed

Lines changed: 62 additions & 22 deletions

.github/workflows/nodejs.yml

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,39 @@ jobs:
4545
run: pnpm run build
4646

4747
test:
48-
name: Node.js
49-
uses: node-modules/github-actions/.github/workflows/node-test.yml@master
50-
with:
51-
os: 'ubuntu-latest, macos-latest, windows-latest'
52-
version: '16, 18, 20, 22, 24'
53-
secrets:
54-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
48+
strategy:
49+
fail-fast: false
50+
matrix:
51+
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
52+
node: ['16', '18', '20', '22', '24']
53+
54+
name: Test (${{ matrix.os }}, ${{ matrix.node }})
55+
runs-on: ${{ matrix.os }}
56+
57+
concurrency:
58+
group: test-${{ github.workflow }}-#${{ github.event.pull_request.number || github.head_ref || github.ref }}-(${{ matrix.os }}, ${{ matrix.node }})
59+
cancel-in-progress: true
60+
61+
steps:
62+
- name: Checkout repository
63+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
64+
65+
- name: Install pnpm
66+
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4
67+
68+
- name: Set up Node.js
69+
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6
70+
with:
71+
node-version: ${{ matrix.node }}
72+
cache: 'pnpm'
73+
74+
- name: Install dependencies
75+
run: pnpm install --frozen-lockfile
76+
77+
- name: Run tests
78+
run: pnpm run ci
79+
80+
- name: Code Coverage
81+
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5
82+
with:
83+
use_oidc: true

src/formstream.d.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
declare module 'formstream' {
2-
export default class FormStream {}
2+
export default class FormStream {
3+
headers(): Record<string, string>;
4+
file(name: string, path: string): void;
5+
field(name: string, value: string): void;
6+
}
37
}

test/HttpClient.test.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { describe, it, beforeAll, afterAll } from 'vitest';
1111
import { HttpClient, RawResponseWithMeta, getGlobalDispatcher } from '../src/index.js';
1212
import { startServer } from './fixtures/server.js';
1313
import { nodeMajorVersion } from './utils.js';
14+
import { AddressInfo } from 'node:net';
1415

1516
const pems = selfsigned.generate([], {
1617
keySize: nodeMajorVersion() >= 22 ? 2048 : 1024,
@@ -157,7 +158,7 @@ describe('HttpClient.test.ts', () => {
157158
},
158159
});
159160

160-
const url = `https://localhost:${server.address()!.port}`;
161+
const url = `https://localhost:${(server.address() as AddressInfo).port}`;
161162
let response = await httpClient.request<string>(url, {
162163
dataType: 'text',
163164
headers: {
@@ -220,7 +221,7 @@ describe('HttpClient.test.ts', () => {
220221
},
221222
});
222223

223-
const url = `https://localhost:${server.address()!.port}`;
224+
const url = `https://localhost:${(server.address() as AddressInfo).port}`;
224225
let response = await httpClient.request<string>(url, {
225226
dataType: 'text',
226227
headers: {
@@ -254,7 +255,7 @@ describe('HttpClient.test.ts', () => {
254255
});
255256

256257
describe('clientOptions.lookup', () => {
257-
it('should work with custom lookup on HTTP protol', async () => {
258+
it('should work with custom lookup on HTTP protocol', async () => {
258259
let lookupCallCounter = 0;
259260
const httpclient = new HttpClient({
260261
// mock lookup delay
@@ -411,7 +412,7 @@ describe('HttpClient.test.ts', () => {
411412

412413
it('should throw error when request address is ip v6', async () => {
413414
const httpclient = new HttpClient({
414-
checkAddress(address, family) {
415+
checkAddress(_address, family) {
415416
return family !== 6;
416417
},
417418
});

test/diagnostics_channel.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import type { RequestDiagnosticsMessage, ResponseDiagnosticsMessage } from '../s
1212
import symbols from '../src/symbols.js';
1313
import { startServer } from './fixtures/server.js';
1414
import { nodeMajorVersion } from './utils.js';
15+
import { AddressInfo } from 'node:net';
1516

1617
describe('diagnostics_channel.test.ts', () => {
1718
let close: any;
@@ -217,7 +218,7 @@ describe('diagnostics_channel.test.ts', () => {
217218
});
218219

219220
let traceId = `mock-traceid-${Date.now()}`;
220-
_url = `https://localhost:${server.address().port}`;
221+
_url = `https://localhost:${(server.address() as AddressInfo).port}`;
221222
let response = await httpClient.request(`${_url}?head=true`, {
222223
method: 'HEAD',
223224
opaque: {

test/fixtures/server.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@ export async function startServer(options?: {
2121
let server: Server;
2222
const requestHandler = async (req: IncomingMessage, res: ServerResponse) => {
2323
const startTime = Date.now();
24-
req.socket[requestsPerSocket] = (req.socket[requestsPerSocket] || 0) + 1;
24+
const socket = req.socket as any;
25+
socket[requestsPerSocket] = (socket[requestsPerSocket] || 0) + 1;
2526
if (server.keepAliveTimeout) {
2627
res.setHeader('Keep-Alive', 'timeout=' + server.keepAliveTimeout / 1000);
2728
}
2829
const urlObject = new URL(req.url!, `http://${req.headers.host}`);
2930
const pathname = urlObject.pathname;
30-
res.setHeader('x-requests-persocket', req.socket[requestsPerSocket]);
31+
res.setHeader('x-requests-persocket', socket[requestsPerSocket]);
3132
res.setHeader('x-requests-socket-port', req.socket.remotePort!);
3233
res.setHeader('X-Foo', 'bar');
3334
res.setHeader('x-href', urlObject.href);
@@ -321,8 +322,8 @@ export async function startServer(options?: {
321322
url: req.url,
322323
href: urlObject.href,
323324
headers: req.headers,
324-
files: {},
325-
form: {},
325+
files: {} as Record<string, any>,
326+
form: {} as Record<string, any>,
326327
};
327328
bb.on('file', (name, file, info) => {
328329
const { filename, encoding, mimeType } = info;

test/fixtures/socket_server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export async function startServer(): Promise<{
1212
const socketPath = `${socketPathPrefix}_${index++}`;
1313
const unixSocketServer = createServer();
1414

15-
unixSocketServer.on('request', (req, res) => {
15+
unixSocketServer.on('request', (_req, res) => {
1616
res.setHeader('Content-Type', 'application/json');
1717
res.write(JSON.stringify({ a: 1 }));
1818
res.end();

test/mts/src/index.mts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// @ts-expect-error ignore type error
12
import { request, IncomingHttpHeaders } from 'urllib';
23
const responseObj = await request('test');
34

test/options.stream.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ describe('options.stream.test.ts', () => {
8989
const response = await urllib.request(`${_url}multipart`, {
9090
method: 'post',
9191
dataType: 'json',
92-
stream: form,
92+
stream: form as any,
9393
headers: form.headers(),
9494
});
9595
assert.equal(response.status, 200);

test/options.timeout.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { describe, it, beforeAll, afterAll } from 'vitest';
88
import urllib, { HttpClientRequestTimeoutError, HttpClient } from '../src/index.js';
99
import { startServer } from './fixtures/server.js';
1010
import { nodeMajorVersion } from './utils.js';
11+
import { AddressInfo } from 'node:net';
1112

1213
const pems = selfsigned.generate([], {
1314
keySize: nodeMajorVersion() >= 22 ? 2048 : 1024,
@@ -93,7 +94,7 @@ describe('options.timeout.test.ts', () => {
9394
server.listen(0);
9495
await once(server, 'listening');
9596

96-
const url = `https://localhost:${server.address()!.port}`;
97+
const url = `https://localhost:${(server.address() as AddressInfo).port}`;
9798
await assert.rejects(
9899
async () => {
99100
await httpClient.request(url, {
@@ -171,7 +172,7 @@ describe('options.timeout.test.ts', () => {
171172
assert.equal(err.res!.status, -1);
172173
assert(err.headers);
173174
assert.equal(err.status, -1);
174-
err.cause && assert.equal(err.cause.name, 'HeadersTimeoutError');
175+
err.cause && assert.equal((err.cause as any).name, 'HeadersTimeoutError');
175176
return true;
176177
},
177178
);

test/urllib.options.rejectUnauthorized-false.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { describe, it, beforeAll, afterAll } from 'vitest';
88
import urllib, { HttpClient } from '../src/index.js';
99
import { startServer } from './fixtures/server.js';
1010
import { nodeMajorVersion } from './utils.js';
11+
import { AddressInfo } from 'node:net';
1112

1213
describe('urllib.options.rejectUnauthorized-false.test.ts', () => {
1314
let close: any;
@@ -60,7 +61,7 @@ describe('urllib.options.rejectUnauthorized-false.test.ts', () => {
6061
},
6162
});
6263

63-
const url = `https://localhost:${server.address()!.port}`;
64+
const url = `https://localhost:${(server.address() as AddressInfo).port}`;
6465
const response1 = await httpClient.request(url, {});
6566
assert.equal(response1.status, 200);
6667
assert.equal(response1.data.toString(), 'hello h2!');

0 commit comments

Comments
 (0)