Bug 2261973 - nodejs-undici: Reports 'undici' User-Agent even when used as NodeJS builtin
Summary: nodejs-undici: Reports 'undici' User-Agent even when used as NodeJS builtin
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: nodejs-undici
Version: rawhide
Hardware: Unspecified
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Jan Staněk
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2024-01-30 16:54 UTC by Jan Staněk
Modified: 2024-02-19 02:27 UTC (History)
2 users (show)

Fixed In Version: nodejs-undici-5.28.3-2.fc40 nodejs-undici-5.28.3-2.fc38 nodejs-undici-5.28.3-2.fc39
Clone Of:
Environment:
Last Closed: 2024-02-09 13:49:52 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github nodejs undici pull 2677 0 None open chore: refine esbuild & node detection 2024-01-31 07:33:39 UTC

Description Jan Staněk 2024-01-30 16:54:05 UTC
When used standalone, undici sends a value of 'undici' in it's User-Agent header. When it's bundled for upstream NodeJS, the bundler makes a slight modification to the code so that it uses 'node' as the value of User-Agent.

The relevant line of code seems to be in `lib/fetch/index.js`:
>     httpRequest.headersList.append('user-agent', typeof esbuildDetection === 'undefined' ? 'undici' : 'node')

The `build:node` script uses the `--define esbuildDetection=1` flag for it's invocation of esbuild, so that in the output .js file, the above line is changed to the following:
>    httpRequest.headersList.append('user-agent', false ? 'undici' : 'node')

Since we use the new way of loading WASM files via dedicated loader, this step is skipped and 'undici' User-Agent used.

Reproducible: Always

Comment 1 Jan Staněk 2024-01-30 16:56:47 UTC
CC @fedora as the original author of the loader: Any suggestions on what to change to carry the user-agent switch even to our way of providing the NodeJS builtin?

Comment 2 Zephyr Lykos 2024-01-31 07:10:25 UTC
a) replace all match of `esbuildDetection` to `1` at build stage (since that's all what esbuild does)
b) add `globalThis.esbuildDetection = 1` to `loader.js`

Comment 3 Zephyr Lykos 2024-01-31 07:14:05 UTC
b), however, will pollute the global namespace, so I think the better way forward is to patch this line / replace it at build stage

Comment 4 Zephyr Lykos 2024-01-31 07:17:40 UTC
An alternative approach is to submit a patch to upstream that isolated this inline detection to a module-wide variable, and do `delete globalThis.esbuildDetection` after requiring the module.

Comment 5 Fedora Update System 2024-02-09 13:46:51 UTC
FEDORA-2024-8aa53b5575 (nodejs-undici-5.28.3-2.fc40) has been submitted as an update to Fedora 40.
https://bodhi.fedoraproject.org/updates/FEDORA-2024-8aa53b5575

Comment 6 Fedora Update System 2024-02-09 13:49:52 UTC
FEDORA-2024-8aa53b5575 (nodejs-undici-5.28.3-2.fc40) has been pushed to the Fedora 40 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 7 Fedora Update System 2024-02-09 14:05:41 UTC
FEDORA-2024-d372314327 (nodejs-undici-5.28.3-2.fc39) has been submitted as an update to Fedora 39.
https://bodhi.fedoraproject.org/updates/FEDORA-2024-d372314327

Comment 8 Fedora Update System 2024-02-09 14:05:46 UTC
FEDORA-2024-963ecc9459 (nodejs-undici-5.28.3-2.fc38) has been submitted as an update to Fedora 38.
https://bodhi.fedoraproject.org/updates/FEDORA-2024-963ecc9459

Comment 9 Fedora Update System 2024-02-10 03:56:19 UTC
FEDORA-2024-963ecc9459 has been pushed to the Fedora 38 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2024-963ecc9459`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2024-963ecc9459

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 10 Fedora Update System 2024-02-11 08:07:56 UTC
FEDORA-2024-d372314327 has been pushed to the Fedora 39 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2024-d372314327`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2024-d372314327

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 11 Fedora Update System 2024-02-18 01:49:52 UTC
FEDORA-2024-963ecc9459 (nodejs-undici-5.28.3-2.fc38) has been pushed to the Fedora 38 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 12 Fedora Update System 2024-02-19 02:27:56 UTC
FEDORA-2024-d372314327 (nodejs-undici-5.28.3-2.fc39) has been pushed to the Fedora 39 stable repository.
If problem still persists, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.