Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
332acfd
Merge branch 'master' into develop (post-v5.1.2)
JCMais Jun 10, 2026
5f55637
fix: emit end promptly for serialized requests on Node.js 26
aborovsky Sep 22, 2026
ac1d8b2
test: cover the polling drain path in the serialized request guard
aborovsky Sep 22, 2026
68ff015
fix: keep the multi async context alive while its callback scope is open
aborovsky Oct 24, 2026
005500e
docs: add changelog entry for the node.js 26 completion dispatch fix
aborovsky Oct 24, 2026
ea7fb3f
fix: defer curl_multi_cleanup when Multi is closed from inside libcurl
JCMais Nov 18, 2026
8f0bc3b
docs: update perform() deferral comment and changelog for Multi close…
JCMais Nov 18, 2026
01c3fe7
fix(win): inline node-addon-api exception settings to avoid MAX_PATH
JCMais Nov 18, 2026
f6531e5
fix: release Multi wrapper after close
JCMais Sep 4, 2026
4b9d25b
fix: update bundled Brotli to 1.2.1
JCMais Nov 24, 2026
24601d7
docs: clarify security support and backport policy
JCMais Nov 24, 2026
16a277a
fix: invalidate HTTP/2 push headers after callback
JCMais Nov 24, 2026
6bb0a9b
fix: align option dispatch and enums with libcurl
JCMais Nov 25, 2026
b6fef17
fix: correct Curl wrapper reuse, streaming, and response parsing
JCMais Nov 25, 2026
44339c5
fix: harden Easy callbacks and option data lifetimes
JCMais Nov 25, 2026
4e7fe2b
fix: manage Multi transfer ownership and HTTP/2 push
JCMais Nov 25, 2026
79c2eaa
docs: add changelog entries for transfer and option fixes
JCMais Nov 25, 2026
54d56d2
chore: prepare CHANGELOG for v5.2.0 release
JCMais Nov 26, 2026
230b9a9
5.2.0
node-libcurl[bot] Nov 26, 2026
28b76cc
docs: document AI usage policy [skip ci]
JCMais Nov 26, 2026
cd40dcf
Merge upstream v5.2.0 into develop
aborovsky Nov 26, 2026
cc18310
ci: install a toolchain for the Alpine arm64 test run
aborovsky Nov 26, 2026
1abdac2
5.2.0-0
github-actions[bot] Nov 26, 2026
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/actions/setup-libcurl-cache/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ runs:
id: cache-key
shell: sh
run: |
echo "cache-key=${{ inputs.cache-key-prefix }}${{ runner.os }}${{ runner.arch == 'ARM64' && '-arm64' || '' }}-${{ steps.detect-libc.outputs.variant }}-libcurl-${{ inputs.libcurl-release }}-deps-cache-${{ inputs.electron-version && 'electron' || 'node' }}-${{ inputs.electron-version || inputs.node-version }}" >> $GITHUB_OUTPUT
echo "cache-key=${{ inputs.cache-key-prefix }}${{ runner.os }}${{ runner.arch == 'ARM64' && '-arm64' || '' }}-${{ steps.detect-libc.outputs.variant }}-libcurl-${{ inputs.libcurl-release }}-deps-cache-${{ inputs.electron-version && 'electron' || 'node' }}-${{ inputs.electron-version || inputs.node-version }}-${{ hashFiles('scripts/ci/build.sh', 'scripts/ci/build-brotli.sh', 'scripts/ci/build-libcurl.sh') }}" >> $GITHUB_OUTPUT
# Restore-only mode (for workflows that save separately)
- name: Restore libcurl deps cache
if: inputs.mode == 'restore-only'
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/build-lint-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ jobs:

- name: 'Run tests (Alpine arm64)'
if: matrix.os == 'alpine-arm64' && matrix.electron-version == ''
# http2PushHeaders.spec compiles a native fixture with node-gyp, which
# needs a toolchain that the bare node:alpine image does not ship.
run: |
PNPM_VERSION=$(node -e "const {packageManager}=require('./package.json');console.log(packageManager.split('@')[1])")
docker run --rm \
Expand All @@ -212,7 +214,11 @@ jobs:
-v "${GITHUB_WORKSPACE}:${GITHUB_WORKSPACE}" \
-w "${GITHUB_WORKSPACE}" \
"node:${{ matrix.node }}-alpine3.22" \
sh -c 'npm install -g pnpm@${PNPM_VERSION} && pnpm test:coverage'
sh -c '
apk add --no-cache python3 make g++ &&
npm install -g pnpm@${PNPM_VERSION} &&
pnpm test:coverage
'

- name: Upload coverage to Codecov
if: matrix.record-coverage && matrix.electron-version != ''
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/windows-consumer-install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ jobs:
$curlVersion
$curlVersionText = $curlVersion -join "`n"

if ($curlVersionText -notmatch '\bbrotli/1\.2\.1\b') {
throw 'Windows curl build did not link the patched Brotli 1.2.1 decoder'
}

if ($curlVersionText -notmatch 'Features:.*\bIDN\b') {
throw 'Windows curl build did not retain IDN support'
}
Expand Down
34 changes: 33 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,37 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Changed

## [5.2.0] - 2026-11-25

### Fixed
- Release the Multi wrapper after `Multi#close()` so it can be collected. ([#457](https://github.com/JCMais/node-libcurl/pull/457), fixes [#453](https://github.com/JCMais/node-libcurl/issues/453))
- HTTP/2 push header accessors throw after the push callback returns. ([#460](https://github.com/JCMais/node-libcurl/pull/460), fixes [#452](https://github.com/JCMais/node-libcurl/issues/452))
- `Multi#perform()` now rejects if its transfer is removed or its Multi is closed. Multi keeps attached Easy handles alive, detaches them during shutdown, and releases their socket watchers. Transfers added without `onMessage` can complete safely, and Multi stops polling sockets when libcurl requests no events. ([#464](https://github.com/JCMais/node-libcurl/pull/464))
- `Curl#close()` now cancels active transfers on their owning Multi, including transfers using `setMulti()`. Closing from a transfer callback defers cleanup until libcurl returns. ([#464](https://github.com/JCMais/node-libcurl/pull/464))
- Restored HTTP/2 server push callbacks on libcurl 8.4 and later. Accepted pushes are tracked by the Multi, and denied pushes close the offered Easy handle. ([#464](https://github.com/JCMais/node-libcurl/pull/464))
- `READFUNCTION` receives a zero-filled buffer and validates the returned byte count. Upload seeks preserve offsets beyond 4 GiB, and file uploads advance by the number of bytes actually read. ([#463](https://github.com/JCMais/node-libcurl/pull/463))
- Callback errors are retained until delivery, and reused Easy handles start with fresh transfer-local progress and HSTS state. `HSTSREADFUNCTION` preserves hostnames at the maximum supported length. ([#463](https://github.com/JCMais/node-libcurl/pull/463))
- Easy handles keep their Share alive while attached. `Share#close()` reports `CURLSHE_IN_USE` while the Share is attached, and automatic Easy cleanup skips callbacks whose JavaScript receiver has been collected. ([#463](https://github.com/JCMais/node-libcurl/pull/463))
- Replacing list or POST data options releases the previous data once outstanding duplicates stop using it. Failed list setup frees temporary data, and repeated MIME attachment on the same handle is tracked once. ([#463](https://github.com/JCMais/node-libcurl/pull/463))
- Fixed socket monitoring setup and teardown errors. `Easy#getInfo()` preserves libcurl's error code directly. ([#463](https://github.com/JCMais/node-libcurl/pull/463))
- `Curl#reset()` clears request state and restores the default user agent. `curly()` returns reused handles to the pool and rejects its promise when request setup fails. ([#462](https://github.com/JCMais/node-libcurl/pull/462))
- Response parsing accepts compact and empty headers and decodes each payload independently. `curly()` honors custom parsers and matches content types regardless of case or whitespace before parameters. ([#462](https://github.com/JCMais/node-libcurl/pull/462))
- Fixed response stream backpressure and resume behavior, detached listeners from replaced upload streams, restored the prior `NOPROGRESS` setting after streaming, and routed response setup errors through a single error event. ([#462](https://github.com/JCMais/node-libcurl/pull/462))
- Fixed `Curl.getCount()` and fixed `Curl#dupHandle()` to preserve the user agent and copy `stream` listeners. ([#462](https://github.com/JCMais/node-libcurl/pull/462))
- Fixed the numeric `TELNETOPTIONS` mapping and enabled native dispatch for existing bindings including `ABSTRACT_UNIX_SOCKET`, `ALTSVC`, `ALTSVC_CTRL`, `FTPSSLAUTH`, `FTP_SSL_CCC`, `MIME_OPTIONS`, `PROXY_ISSUERCERT_BLOB`, `SSH_HOSTKEYFUNCTION`, `SSH_HOST_PUBLIC_KEY_SHA256`, `TFTP_NO_OPTIONS`, `WS_OPTIONS`, and `INTERLEAVEFUNCTION`. ([#461](https://github.com/JCMais/node-libcurl/pull/461))
- Corrected `CurlSshKeyType` numeric values to match libcurl. `CurlMultiNetworkChanged.ClearConns` and `.ClearDns` clear their respective caches on libcurl 8.20 and later, while both retain the combined behavior on libcurl 8.16–8.19. ([#461](https://github.com/JCMais/node-libcurl/pull/461))
- Updated bundled Brotli to 1.2.1 on all platforms to fix [CVE-2026-111497](https://www.cve.org/CVERecord?id=CVE-2026-111497), an out-of-bounds write in the decoder. ([#456](https://github.com/JCMais/node-libcurl/issues/456))
- Fixed `end` (and the promise returned by `Multi#perform`) not being delivered on Node.js 26 until some other JavaScript callback ran, which made requests awaited one at a time take ~1s each (libcurl's multi timer period) or never complete in an otherwise idle process. `Multi::OnSocket` and `Multi::OnTimeout` called into JavaScript from libuv without a callback scope, so the microtask queue was not drained afterwards. Before Node.js 26.4.0 an unrelated drain in `CheckImmediate` hid this ([nodejs/node#62969](https://github.com/nodejs/node/pull/62969)). Both now open a `Napi::CallbackScope`. As a side effect, `process.nextTick` callbacks and microtasks queued from inside data, header, progress, and other easy callbacks now run once the libuv callback that dispatched them returns, instead of after each individual callback. This matches how Node.js core runs callbacks. ([#455](https://github.com/JCMais/node-libcurl/pull/455), fixes [#454](https://github.com/JCMais/node-libcurl/issues/454))
- Fixed the process aborting with `Assertion failed: (code == CURLM_OK), function Dispose` when `Multi#close` is called from inside `onMessage` on libcurl >= 8.17 (where the notifications API is the default, as in `examples/04-multi.js`), or from inside an easy callback such as `WRITEFUNCTION` with any libcurl version. libcurl rejects `curl_multi_cleanup` with `CURLM_RECURSIVE_API_CALL` while it is running its own callbacks, so the cleanup is now deferred until `curl_multi_socket_action` returns.
- Fixed building from source on Windows with Visual Studio 2026 (MSBuild 18) when node-libcurl is installed in a deeply nested folder, such as a pnpm store inside a monorepo. The build failed with `PathTooLongException` in `WriteLinesToFile` because gyp generated a project for node-addon-api's header-only `node_addon_api_except` target next to node-addon-api's own folder, and MSBuild wrote its intermediate files there. On Windows its settings are now set directly in `binding.gyp`.

### Added
- Added `Curl.info.SIZE_DELIVERED` and the `QUICK_EXIT` and `RESOLVE_THREADS_MAX` Multi options on libcurl 8.20 and later. ([#461](https://github.com/JCMais/node-libcurl/pull/461))
- Added `CurlAltSvc` and the enum members `CurlFileType.Unknown`, `CurlMultiNetworkChanged.ClearAll`, `CurlSshKeyType.Rsa1`, `CurlSshKeyMatch.Missing`, `CurlVersion.Hsts`, and `CurlVersion.ThreadSafe`. ([#461](https://github.com/JCMais/node-libcurl/pull/461))

### Changed
- The security policy supports v5 and describes when a fix may be offered for the previous major version. ([#459](https://github.com/JCMais/node-libcurl/pull/459))

## [5.1.2] - 2026-06-08

### Fixed
Expand Down Expand Up @@ -548,7 +579,8 @@ Special Thanks to [@koskokos2](https://github.com/koskokos2) for their contribut
- Improved code style, started using prettier
## [1.2.0] - 2017-08-28

[Unreleased]: https://github.com/JCMais/node-libcurl/compare/v5.1.2...HEAD
[Unreleased]: https://github.com/JCMais/node-libcurl/compare/v5.2.0...HEAD
[5.2.0]: https://github.com/JCMais/node-libcurl/compare/v5.1.2...v5.2.0
[5.1.2]: https://github.com/JCMais/node-libcurl/compare/v5.1.1...v5.1.2
[5.1.1]: https://github.com/JCMais/node-libcurl/compare/v5.1.0...v5.1.1
[5.1.0]: https://github.com/JCMais/node-libcurl/compare/v5.0.2...v5.1.0
Expand Down
9 changes: 9 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Contributing<!-- omit in toc -->

- [AI usage policy](#ai-usage-policy)
- [Contributing with Issues](#contributing-with-issues)
- [Contributing with Code](#contributing-with-code)
- [C/C++](#cc)
Expand All @@ -19,6 +20,14 @@
- [Prereleases](#prereleases)
- [Build Matrix](#build-matrix)

## AI usage policy

AI tools are welcome in node-libcurl. Disclosure is optional. You should assume AI was involved in all recent contributions, including work by maintainers.

You’re responsible for everything you submit. For a pull request, understand the changes, run the relevant checks, and be ready to explain your decisions during review. For a bug report, verify the finding yourself and describe what you observed. Keep submissions focused so maintainers can review them efficiently.

We close low-effort submissions that shift basic verification to maintainers. This includes unverified claims, changes the contributor can’t explain, and generated reports that bury the issue. The same standards apply to everyone, including maintainers.

## Contributing with Issues

Before opening an issue try to search the existing ones for the same problem.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ Installing with `yarn add node-libcurl` or `npm install node-libcurl` should dow

The prebuilt binary is statically built with the following library versions, features and protocols (library versions may change between Node.js versions):
```
Version: libcurl/8.17.0 OpenSSL/3.5.2 zlib/1.3.1 brotli/1.1.0 zstd/1.5.7 libidn2/2.1.1 libssh2/1.10.0 nghttp2/1.66.0 ngtcp2/1.17.0 nghttp3/1.12.0 OpenLDAP/2.6.9
Version: libcurl/8.17.0 OpenSSL/3.5.2 zlib/1.3.1 brotli/1.2.1 zstd/1.5.7 libidn2/2.1.1 libssh2/1.10.0 nghttp2/1.66.0 ngtcp2/1.17.0 nghttp3/1.12.0 OpenLDAP/2.6.9
Protocols: dict, file, ftp, ftps, gopher, gophers, http, https, imap, imaps, ldap, ldaps, mqtt, pop3, pop3s, rtsp, scp, sftp, smb, smbs, smtp, smtps, telnet, tftp, ws, wss
Features: AsynchDNS, IDN, IPv6, Largefile, NTLM, SSL, libz, brotli, TLS-SRP, HTTP2, UnixSockets, HTTPS-proxy, alt-svc
```
Expand All @@ -293,7 +293,7 @@ npm_config_build_from_source=true yarn add node-libcurl

The prebuilt binaries are statically linked with `brotli`, `libidn2`, `libssh2`, `openLDAP`, `OpenSSL` `nghttp2`, `zstd` and `zlib`.

The `brotli`, `nghttp2`, `OpenSSL` and `zlib` versions **must** match the version Node.js uses, this is necessary to avoid any possible issues by mixing library symbols of different versions, since Node.js also exports some of the symbols of their deps.
The `nghttp2`, `OpenSSL` and `zlib` versions **must** match the version Node.js uses to avoid mixing library symbols from different versions. The build pins Brotli separately to a patched release. Keep Node.js or Electron up to date to patch the runtime's own decoder.

In case you are building the addon yourself with the libraries mentioned above, you must make sure their version is ABI compatible with the one Node.js uses, otherwise you are probably going to hit a Segmentation Fault.

Expand Down
10 changes: 7 additions & 3 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@

## Supported Versions

The following versions are going to receive security updates. The updates will take form as minor version increments.
Only v5 is supported. Security updates for supported versions are released as minor version increments.

| Version | Supported |
| ------- | ------------------ |
| 2.1.0 | :white_check_mark: |
| < 2.0.0 | :x: |
| 5.x | :white_check_mark: |
| < 5.0.0 | :x: |

We may backport a fix to the immediately previous major version for a serious
security vulnerability when affected users have no practical workaround.
Building from source with a patched dependency may be a workaround when feasible.

## Reporting a Vulnerability

Expand Down
35 changes: 28 additions & 7 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@
{
'target_name': '<(module_name)',
'type': 'loadable_module',
'dependencies': [
# https://github.com/nodejs/node-addon-api/blob/main/doc/setup.md
# using exceptions (instead of maybe, like we used to have on nan)
"<!(node -p \"require('node-addon-api').targets\"):node_addon_api_except",
],
# node-addon-api is used with C++ exceptions (instead of maybe, like we
# used to have on nan), see
# https://github.com/nodejs/node-addon-api/blob/main/doc/setup.md
# On Windows the settings from its node_addon_api_except target are
# inlined below, see the comment there.
'sources': [
'src/node_libcurl.cc',
'src/Easy.cc',
Expand Down Expand Up @@ -107,7 +107,9 @@
'/std:<(node_libcurl_cpp_std)',
'/MP', #compile across multiple CPUs
],
"ExceptionHandling": 1,
"ExceptionHandling": 1,
# From node-addon-api's except.gypi, see the defines below.
'EnablePREfast': 'true',
},
'VCLinkerTool': {
'AdditionalOptions': [
Expand Down Expand Up @@ -150,7 +152,18 @@
'<!@(node "<(module_root_dir)/scripts/openssl-disable.js")'
],
'defines': [
'CURL_STATICLIB'
'CURL_STATICLIB',
# Inlined from node-addon-api's except.gypi instead of depending on
# its node_addon_api_except target. That target is header-only,
# but the msvs generator still emits a .vcxproj for it next to
# node-addon-api's real location, which in a pnpm store is a
# sibling of node-libcurl's own folder, and MSBuild writes its
# intermediate files there. In a deeply nested consumer those
# paths pass MAX_PATH, and MSBuild 18 (Visual Studio 2026) fails
# with PathTooLongException in WriteLinesToFile.
# Keep in sync with node_modules/node-addon-api/except.gypi.
'NAPI_CPP_EXCEPTIONS',
'_HAS_EXCEPTIONS=1',
],
'conditions': [
['curl_include_dirs==""', {
Expand All @@ -167,6 +180,9 @@
}]
]
}, { # OS != "win"
'dependencies': [
"<!(node -p \"require('node-addon-api').targets\"):node_addon_api_except",
],
# Use level 2 optimizations
'cflags': [
'-O2',
Expand Down Expand Up @@ -204,6 +220,11 @@
],
}],
['curl_static_build=="true"', {
# Keep libcurl on its bundled Brotli decoder when the host
# runtime exports its own copy of the same symbols.
'ldflags': [
'-Wl,--exclude-libs,libbrotlidec.a:libbrotlicommon.a',
],
# pretty sure cflags adds that
'defines': [
'CURL_STATICLIB',
Expand Down
Loading
Loading