Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
node: ['22', '24', '25']
node: ['22', '24', '26']

name: Test (${{ matrix.os }}, ${{ matrix.node }})
runs-on: ${{ matrix.os }}
Expand Down
13 changes: 13 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# https://docs.codecov.com/docs/codecovyml-reference
coverage:
status:
project:
default:
# Tolerate small coverage fluctuations caused by flaky network/timing
# and OS-specific error paths across the test matrix.
target: auto
threshold: 1%
patch:
default:
target: auto
threshold: 1%
5 changes: 3 additions & 2 deletions test/diagnostics_channel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('diagnostics_channel.test.ts', () => {
const handler = request[kHandler];
if (!handler) return;
let opaque = handler.opaque || handler.opts?.opaque;
assert(opaque);
if (!opaque) return;
opaque = opaque[kRequestOriginalOpaque];
if (opaque && name === 'undici:client:sendHeaders' && socket) {
socket[kRequests]++;
Expand Down Expand Up @@ -187,8 +187,9 @@ describe('diagnostics_channel.test.ts', () => {
}
}
const handler = request[kHandler];
if (!handler) return;
let opaque = handler.opaque || handler.opts?.opaque;
assert(opaque);
if (!opaque) return;
opaque = opaque[kRequestOriginalOpaque];
if (opaque && name === 'undici:client:sendHeaders' && socket) {
socket[kRequests]++;
Expand Down
17 changes: 17 additions & 0 deletions test/setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Agent, Dispatcher, getGlobalDispatcher, setGlobalDispatcher } from 'undici';

// On Node.js >= 26 the runtime ships its own (newer) built-in undici. Under the
// Vitest fork pool that built-in undici can win the shared global dispatcher
// symbol (`Symbol.for('undici.globalDispatcher.1')`) before this package's
// undici is loaded. When that happens `getGlobalDispatcher()` returns a
// cross-version compatibility wrapper (`Dispatcher1Wrapper`) whose handler is a
// `LegacyHandlerWrapper` that keeps the request `opaque` in private fields,
// hiding it from our diagnostics_channel instrumentation. As a result request
// timing and socket tracing silently stop working in tests.
//
// Real-world usage is not affected: when an application imports this package
// (and therefore undici) the npm undici wins the global dispatcher symbol. Reset
// the global dispatcher here so the test environment matches that behaviour.
if (!(getGlobalDispatcher() instanceof Dispatcher)) {
setGlobalDispatcher(new Agent());
}
1 change: 1 addition & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ export default defineConfig({
// plugins: [codspeedPlugin()],
test: {
include: ['test/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
setupFiles: ['./test/setup.ts'],
testTimeout: 60000,
coverage: {
include: ['src'],
Expand Down
Loading