Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
b696a78
In CITGM, skip tests that are flaky there (#3413)
mcollina Jul 22, 2024
99102cc
Bumped v6.19.3
mcollina Jul 22, 2024
e51aa88
Update esbuild to 0.19.10 (#3415)
mcollina Jul 22, 2024
62241c3
Bumped v6.19.4
mcollina Jul 22, 2024
93605ab
fix: restore externalized Node.js dep compatibility (#3421)
richardlau Jul 29, 2024
8499c4b
Bumped v6.19.5
mcollina Jul 31, 2024
638ee32
fix: memory leak in finalization first appearing in v6.16.0 (#3445)
snyamathi Aug 9, 2024
b9bf7ad
Bumped v6.19.6
mcollina Aug 9, 2024
09c5667
build: remove -i flag to docker run to allow command being run withou…
mcollina Aug 9, 2024
c81f5a7
Bumped v6.19.7
mcollina Aug 9, 2024
5287054
test: add test for memory leak (#3450)
snyamathi Aug 14, 2024
bc46332
build: parametrize the location of wasm-opt (#3454)
khardix Aug 14, 2024
405a2ce
use bodyUnusable to check if body is unusable (#3460)
KhafraDev Aug 15, 2024
dbb6b40
perf: non-recursive implementation of euclidian gcd in balanced pool …
Uzlopak Aug 15, 2024
cde714f
use FinalizationRegistry for cloned response body (#3458)
KhafraDev Aug 15, 2024
3d3ce06
Bumped v6.19.8
mcollina Aug 19, 2024
8d28413
Remove patched dom types (`v6.x` branch) (#3531)
eXhumer Sep 2, 2024
be0c779
docs(Backport v6.x): Fix signature of RetryHandler (#3594)
github-actions[bot] Sep 12, 2024
f93d857
deps(dev): update @types/node (#3618)
metcoder95 Sep 18, 2024
9936184
fix: throw on retry when payload is consume by downstream (#3596)
github-actions[bot] Sep 18, 2024
52ae2f0
feat(Backport v6.x): move throwOnError to interceptor (#3595)
github-actions[bot] Sep 18, 2024
7466672
fix: avoid memoryleak in client-h1 (#3510) (#3672)
github-actions[bot] Oct 3, 2024
6764626
fix: refactor fast timers, fix UND_ERR_CONNECT_TIMEOUT on event loop …
github-actions[bot] Oct 4, 2024
a7bffd4
fix: run asserts first if possible (#3541) (#3674)
github-actions[bot] Oct 4, 2024
d047e99
fix: use fasttimers for all connection timeouts (#3552) (#3675)
github-actions[bot] Oct 4, 2024
5b1e534
ci: less flaky test/request-timeout.js test (#3580) (#3678)
github-actions[bot] Oct 4, 2024
5c0846d
test: less flaky timers acceptance test, rework fast timer tests to p…
github-actions[bot] Oct 4, 2024
de943c4
ignore leading and trailing crlfs in formdata body (#3677) (#3681)
github-actions[bot] Oct 5, 2024
1df3923
mock: fix mocking of Uint8Array and ArrayBuffers as provided mock-rep…
github-actions[bot] Oct 7, 2024
e4439e9
handle body errors (#3632) (#3700)
Uzlopak Oct 8, 2024
24b9403
Bumped v6.20.0
mcollina Oct 9, 2024
5be8ebf
jsdoc: add jsdoc to lib/web/fetch/constants.js (#3597) (#3710)
github-actions[bot] Oct 10, 2024
4869e5e
feat: implement `BodyReadable.bytes` (#3391) (#3711)
github-actions[bot] Oct 10, 2024
39c5974
fix: add more expectsPayload methods (#3715)
ronag Oct 11, 2024
a699105
chore(H2): onboard H2 into Undici queueing system (#3707) (#3724)
Uzlopak Oct 12, 2024
fd32a55
fix: PoolBase kClose and kDestroy should await and not return the Pro…
github-actions[bot] Oct 12, 2024
5415911
fix: extract noop everywhere (#3559) (#3727)
Uzlopak Oct 13, 2024
5344aa5
6.20.1
ronag Oct 14, 2024
e2e3fd2
web: mark as uncloneable when possible (#3709) (#3744)
jazelly Oct 17, 2024
f21da44
fetch: fix content-encoding order (#3343) (#3764)
github-actions[bot] Oct 23, 2024
98d1b1b
fix: handle undefined deref() of WeakRef(socket) (#3751) (#3822)
github-actions[bot] Nov 11, 2024
11e31a4
fix: range end is zero-indexed (#3826) (#3827)
github-actions[bot] Nov 12, 2024
61ec353
Bumped v6.21.0
mcollina Nov 13, 2024
353ab63
fix(#3736): back-port 183f8e9 to v6.x (#3855)
ggoodman Nov 21, 2024
a0220f1
fix(#3817): send servername for SNI on TLS (#3821) [backport] (#3864)
metcoder95 Nov 22, 2024
ee6176c
fix: sending formdata bodies with http2 (#3863) [backport] (#3866)
metcoder95 Nov 22, 2024
be8cd0a
[Backport v6.x] fix: Fixed the issue that there is no running request…
github-actions[bot] Nov 24, 2024
2414bc9
Update return type of RetryCallback (#3851) (#3876)
metcoder95 Nov 25, 2024
c3acc60
Merge commit from fork
mcollina Jan 16, 2025
e260e7b
Bumped v6.21.1
mcollina Jan 16, 2025
a0e76c7
fix(types): add missing DNS interceptor (#4024)
slagiewka Feb 16, 2025
1333871
Removed clients with unrecoverable errors from the Pool (#4088)
mcollina Mar 12, 2025
4e07dda
test: fix windows wpt (#4050)
metcoder95 Feb 9, 2025
de1e4b8
[v6.x] fix wpts on windows (#4093)
mcollina Mar 13, 2025
b63d939
Bumped v6.21.2
mcollina Mar 13, 2025
dbbe0a2
append crlf to formdata body (#3625) (#4210)
github-actions[bot] May 12, 2025
e525216
Bumped v6.21.3
invalid-email-address May 12, 2025
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
102 changes: 102 additions & 0 deletions .github/workflows/nodejs-shared.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Node.js compiled --shared-builtin-undici/undici-path CI

on:
push:
branches:
- main
- current
- next
- 'v*'
pull_request:

permissions:
contents: read

jobs:
test-shared-builtin:
name: Test with Node.js ${{ matrix.version }} compiled --shared-builtin-undici/undici-path
strategy:
fail-fast: false
max-parallel: 0
matrix:
version: [20, 22]
runs-on: ubuntu-latest
timeout-minutes: 120
steps:
# Checkout into a subdirectory otherwise Node.js tests will break due to finding Undici's package.json in a parent directory.
- name: Checkout
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
with:
path: ./undici
persist-credentials: false

# Setup node, install deps, and build undici prior to building node with `--shared-builtin-undici/undici-path` and testing
- name: Setup Node.js@${{ inputs.version }}
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: ${{ inputs.version }}

- name: Install dependencies
working-directory: ./undici
run: npm install

- name: Install wasi-libc
run: sudo apt-get install -y wasi-libc

- name: Build WASM
working-directory: ./undici
run: |
export EXTERNAL_PATH=${{ github.workspace }}/undici
export WASM_CC=clang
export WASM_CFLAGS='--target=wasm32-wasi --sysroot=/usr'
export WASM_LDFLAGS='-nodefaultlibs'
export WASM_LDLIBS='-lc'
node build/wasm.js

- name: Determine latest release
id: release
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
result-encoding: string
script: |
const req = await fetch('https://nodejs.org/download/release/index.json')
const releases = await req.json()

const latest = releases.find((r) => r.version.startsWith('v${{ matrix.version }}'))
return latest.version

- name: Download and extract source
run: curl https://nodejs.org/download/release/${{ steps.release.outputs.result }}/node-${{ steps.release.outputs.result }}.tar.xz | tar xfJ -

- name: Install ninja
run: sudo apt-get install ninja-build

- name: ccache
uses: hendrikmuhs/ccache-action@c92f40bee50034e84c763e33b317c77adaa81c92 #v1.2.13
with:
key: node(external_undici)${{ matrix.version }}

- name: Build node
working-directory: ./node-${{ steps.release.outputs.result }}
run: |
export CC="ccache gcc"
export CXX="ccache g++"
rm -rf deps/undici
./configure --shared-builtin-undici/undici-path ${{ github.workspace }}/undici/loader.js --ninja --prefix=./final
make
make install
echo "$(pwd)/final/bin" >> $GITHUB_PATH

- name: Print version information
run: |
echo OS: $(node -p "os.version()")
echo Node.js: $(node --version)
echo npm: $(npm --version)
echo git: $(git --version)
echo external config: $(node -e "console.log(process.config)" | grep NODE_SHARED_BUILTIN_UNDICI_UNDICI_PATH)
echo Node.js built-in undici version: $(node -p "process.versions.undici") # undefined for external Undici

- name: Run tests
working-directory: ./node-${{ steps.release.outputs.result }}
run: tools/test.py -p dots --flaky-tests=dontcare

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,6 @@ undici-fetch.js
.npmrc

.tap

# File generated by /test/request-timeout.js
test/request-timeout.10mb.bin
3 changes: 3 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ lib/llhttp/llhttp.wasm
!index.d.ts
!docs/docs/**/*
!scripts/strip-comments.js

# File generated by /test/request-timeout.js
test/request-timeout.10mb.bin
4 changes: 3 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ If you are packaging `undici` for a distro, this might help if you would like to
an unbundled version instead of bundling one in `libnode.so`.

To enable this, pass `EXTERNAL_PATH=/path/to/global/node_modules/undici` to `build/wasm.js`.
You shall also pass this path to `--shared-builtin-undici/undici-path` in Node.js's `configure.py`.
Pass this path with `loader.js` appended to `--shared-builtin-undici/undici-path` in Node.js's `configure.py`.
If building on a non-Alpine Linux distribution, you may need to also set the `WASM_CC`, `WASM_CFLAGS`, `WASM_LDFLAGS` and `WASM_LDLIBS` environment variables before running `build/wasm.js`.
Similarly, you can set the `WASM_OPT` environment variable to utilize your own `wasm-opt` optimizer.

<a id="benchmarks"></a>
### Benchmarks
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ The `body` mixins are the most common way to format the request/response body. M

- [`.arrayBuffer()`](https://fetch.spec.whatwg.org/#dom-body-arraybuffer)
- [`.blob()`](https://fetch.spec.whatwg.org/#dom-body-blob)
- [`.bytes()`](https://fetch.spec.whatwg.org/#dom-body-bytes)
- [`.json()`](https://fetch.spec.whatwg.org/#dom-body-json)
- [`.text()`](https://fetch.spec.whatwg.org/#dom-body-text)

Expand Down
18 changes: 18 additions & 0 deletions benchmarks/timers/compare-timer-getters.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { bench, group, run } from 'mitata'

group('timers', () => {
bench('Date.now()', () => {
Date.now()
})
bench('performance.now()', () => {
performance.now()
})
bench('Math.trunc(performance.now())', () => {
Math.trunc(performance.now())
})
bench('process.uptime()', () => {
process.uptime()
})
})

await run()
61 changes: 41 additions & 20 deletions build/wasm.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ const WASM_CC = process.env.WASM_CC || 'clang'
let WASM_CFLAGS = process.env.WASM_CFLAGS || '--sysroot=/usr/share/wasi-sysroot -target wasm32-unknown-wasi'
let WASM_LDFLAGS = process.env.WASM_LDFLAGS || ''
const WASM_LDLIBS = process.env.WASM_LDLIBS || ''
const WASM_OPT = process.env.WASM_OPT || './wasm-opt'

// For compatibility with Node.js' `configure --shared-builtin-undici/undici-path ...`
const EXTERNAL_PATH = process.env.EXTERNAL_PATH

// These are relevant for undici and should not be overridden
WASM_CFLAGS += ' -Ofast -fno-exceptions -fvisibility=hidden -mexec-model=reactor'
Expand Down Expand Up @@ -59,7 +63,7 @@ if (process.argv[2] === '--prebuild') {
}

if (process.argv[2] === '--docker') {
let cmd = `docker run --rm -it --platform=${platform.toString().trim()}`
let cmd = `docker run --rm -t --platform=${platform.toString().trim()}`
if (process.platform === 'linux') {
cmd += ` --user ${process.getuid()}:${process.getegid()}`
}
Expand All @@ -73,6 +77,9 @@ if (process.argv[2] === '--docker') {
const hasApk = (function () {
try { execSync('command -v apk'); return true } catch (error) { return false }
})()
const hasOptimizer = (function () {
try { execSync(`${WASM_OPT} --version`); return true } catch (error) { return false }
})()
if (hasApk) {
// Gather information about the tools used for the build
const buildInfo = execSync('apk info -v').toString()
Expand All @@ -81,24 +88,38 @@ if (hasApk) {
process.exit(-1)
}
console.log(buildInfo)
}

// Build wasm binary
execSync(`${WASM_CC} ${WASM_CFLAGS} ${WASM_LDFLAGS} \
${join(WASM_SRC, 'src')}/*.c \
-I${join(WASM_SRC, 'include')} \
-o ${join(WASM_OUT, 'llhttp.wasm')} \
${WASM_LDLIBS}`, { stdio: 'inherit' })

if (hasOptimizer) {
execSync(`${WASM_OPT} ${WASM_OPT_FLAGS} -o ${join(WASM_OUT, 'llhttp.wasm')} ${join(WASM_OUT, 'llhttp.wasm')}`, { stdio: 'inherit' })
}
writeWasmChunk('llhttp.wasm', 'llhttp-wasm.js')

// Build wasm binary
execSync(`${WASM_CC} ${WASM_CFLAGS} ${WASM_LDFLAGS} \
${join(WASM_SRC, 'src')}/*.c \
-I${join(WASM_SRC, 'include')} \
-o ${join(WASM_OUT, 'llhttp.wasm')} \
${WASM_LDLIBS}`, { stdio: 'inherit' })

execSync(`./wasm-opt ${WASM_OPT_FLAGS} -o ${join(WASM_OUT, 'llhttp.wasm')} ${join(WASM_OUT, 'llhttp.wasm')}`, { stdio: 'inherit' })
writeWasmChunk('llhttp.wasm', 'llhttp-wasm.js')

// Build wasm simd binary
execSync(`${WASM_CC} ${WASM_CFLAGS} -msimd128 ${WASM_LDFLAGS} \
${join(WASM_SRC, 'src')}/*.c \
-I${join(WASM_SRC, 'include')} \
-o ${join(WASM_OUT, 'llhttp_simd.wasm')} \
${WASM_LDLIBS}`, { stdio: 'inherit' })

execSync(`./wasm-opt ${WASM_OPT_FLAGS} --enable-simd -o ${join(WASM_OUT, 'llhttp_simd.wasm')} ${join(WASM_OUT, 'llhttp_simd.wasm')}`, { stdio: 'inherit' })
writeWasmChunk('llhttp_simd.wasm', 'llhttp_simd-wasm.js')
// Build wasm simd binary
execSync(`${WASM_CC} ${WASM_CFLAGS} -msimd128 ${WASM_LDFLAGS} \
${join(WASM_SRC, 'src')}/*.c \
-I${join(WASM_SRC, 'include')} \
-o ${join(WASM_OUT, 'llhttp_simd.wasm')} \
${WASM_LDLIBS}`, { stdio: 'inherit' })

if (hasOptimizer) {
execSync(`${WASM_OPT} ${WASM_OPT_FLAGS} --enable-simd -o ${join(WASM_OUT, 'llhttp_simd.wasm')} ${join(WASM_OUT, 'llhttp_simd.wasm')}`, { stdio: 'inherit' })
}
writeWasmChunk('llhttp_simd.wasm', 'llhttp_simd-wasm.js')

// For compatibility with Node.js' `configure --shared-builtin-undici/undici-path ...`
if (EXTERNAL_PATH) {
writeFileSync(join(ROOT, 'loader.js'), `
'use strict'
globalThis.__UNDICI_IS_NODE__ = true
module.exports = require('node:module').createRequire('${EXTERNAL_PATH}/loader.js')('./index-fetch.js')
delete globalThis.__UNDICI_IS_NODE__
`)
}
Loading