Skip to content

feat(dev): use web fetch handler rather than proxy - #1051

Merged
danielroe merged 9 commits into
mainfrom
feat/socket-fetch
Sep 26, 2025
Merged

feat(dev): use web fetch handler rather than proxy#1051
danielroe merged 9 commits into
mainfrom
feat/socket-fetch

Conversation

@danielroe

Copy link
Copy Markdown
Member

🔗 Linked issue

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

this aims to fix some bugs in the current proxy implementation by dropping httpxy and using fetch directly (as nitro does).

much of the implementation is copied from nitro (thank you @pi0 - do you spot any issues here or things we can improve further?):

@github-actions

github-actionsBot commented Sep 24, 2025

Copy link
Copy Markdown
Contributor

Bundle Stats — create-nuxt size comparison

Hey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle.

As this PR is updated, I'll keep you updated on how the bundle size is impacted.

Total

Files countTotal bundle size% Changed
72.13 MB0%

Changeset

No files were changed

View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

No assets were bigger

Smaller

No assets were smaller

Unchanged

AssetFile Size% Changed
index.mjs1.09 kB0%
chunks/multipart-parser.mjs5.11 kB0%
chunks/multipart-parser2.mjs4.58 kB0%
chunks/prompt.mjs42.91 kB0%
chunks/index.mjs904.13 kB0%
chunks/satisfies.mjs116 B0%
shared/create-nuxt.BZoiezHJ.mjs1.19 MB0%

@github-actions

github-actionsBot commented Sep 24, 2025

Copy link
Copy Markdown
Contributor

Bundle Stats — nuxi size comparison

Hey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle.

As this PR is updated, I'll keep you updated on how the bundle size is impacted.

Total

Files countTotal bundle size% Changed
583.62 MB → 4.5 MB (+909.88 kB)+24.58%
Changeset (largest 100 files by percent change)
FileΔSize
node_modules/undici/lib/web/fetch/index.js🆕 +79.91 kB0 B → 79.91 kB
node_modules/undici/lib/llhttp/llhttp_simd-wasm.js🆕 +63.62 kB0 B → 63.62 kB
node_modules/undici/lib/llhttp/llhttp-wasm.js🆕 +63.54 kB0 B → 63.54 kB
node_modules/undici/lib/web/fetch/util.js🆕 +50.68 kB0 B → 50.68 kB
node_modules/undici/lib/dispatcher/client-h1.js🆕 +38.09 kB0 B → 38.09 kB
node_modules/undici/lib/web/fetch/request.js🆕 +34.82 kB0 B → 34.82 kB
node_modules/undici/lib/web/fetch/data-url.js🆕 +22.3 kB0 B → 22.3 kB
node_modules/undici/lib/web/cache/cache.js🆕 +21.46 kB0 B → 21.46 kB
node_modules/undici/lib/web/fetch/webidl.js🆕 +20.84 kB0 B → 20.84 kB
node_modules/undici/lib/web/fetch/headers.js🆕 +20.83 kB0 B → 20.83 kB
node_modules/undici/lib/core/util.js🆕 +19.31 kB0 B → 19.31 kB
node_modules/undici/lib/web/fetch/response.js🆕 +19.2 kB0 B → 19.2 kB
node_modules/undici/lib/dispatcher/client-h2.js🆕 +19.08 kB0 B → 19.08 kB
node_modules/undici/lib/web/websocket/websocket.js🆕 +18.71 kB0 B → 18.71 kB
node_modules/undici/lib/web/fetch/body.js🆕 +17.59 kB0 B → 17.59 kB
node_modules/undici/lib/dispatcher/client.js🆕 +17.22 kB0 B → 17.22 kB
node_modules/undici/lib/web/fetch/formdata-parser.js🆕 +15.45 kB0 B → 15.45 kB
node_modules/undici/lib/web/eventsource/eventsource.js🆕 +14.34 kB0 B → 14.34 kB
node_modules/undici/lib/web/websocket/connection.js🆕 +14.25 kB0 B → 14.25 kB
node_modules/undici/lib/web/websocket/receiver.js🆕 +13.86 kB0 B → 13.86 kB
node_modules/undici/lib/web/cookies/parse.js🆕 +12.5 kB0 B → 12.5 kB
node_modules/undici/lib/util/timers.js🆕 +12 kB0 B → 12 kB
node_modules/undici/lib/web/eventsource/eventsource-stream.js🆕 +11.9 kB0 B → 11.9 kB
node_modules/undici/lib/web/fileapi/util.js🆕 +11.69 kB0 B → 11.69 kB
node_modules/undici/lib/llhttp/constants.js🆕 +11.3 kB0 B → 11.3 kB
node_modules/undici/lib/mock/mock-utils.js🆕 +11.01 kB0 B → 11.01 kB
node_modules/undici/lib/core/request.js🆕 +10.74 kB0 B → 10.74 kB
node_modules/undici/lib/handler/retry-handler.js🆕 +10.11 kB0 B → 10.11 kB
node_modules/undici/lib/interceptor/dns.js🆕 +9.57 kB0 B → 9.57 kB
node_modules/undici/lib/api/readable.js🆕 +9.31 kB0 B → 9.31 kB
node_modules/undici/lib/web/websocket/util.js🆕 +9.27 kB0 B → 9.27 kB
node_modules/undici/lib/web/fileapi/filereader.js🆕 +8.79 kB0 B → 8.79 kB
node_modules/srvx/dist/adapters/node.mjs🆕 +7.96 kB0 B → 7.96 kB
node_modules/undici/lib/web/fetch/formdata.js🆕 +7.84 kB0 B → 7.84 kB
node_modules/undici/lib/web/cookies/util.js🆕 +7.59 kB0 B → 7.59 kB
node_modules/undici/lib/web/websocket/events.js🆕 +7.57 kB0 B → 7.57 kB
node_modules/undici/lib/core/connect.js🆕 +7.49 kB0 B → 7.49 kB
node_modules/undici/lib/mock/mock-interceptor.js🆕 +7.02 kB0 B → 7.02 kB
node_modules/undici/lib/handler/redirect-handler.js🆕 +6.9 kB0 B → 6.9 kB
node_modules/undici/lib/web/fileapi/encoding.js🆕 +6.88 kB0 B → 6.88 kB
node_modules/undici/lib/core/errors.js🆕 +6.69 kB0 B → 6.69 kB
node_modules/undici/lib/dispatcher/proxy-agent.js🆕 +6.14 kB0 B → 6.14 kB
node_modules/undici/lib/api/api-request.js🆕 +5.96 kB0 B → 5.96 kB
node_modules/undici/lib/core/diagnostics.js🆕 +5.91 kB0 B → 5.91 kB
node_modules/undici/lib/dispatcher/balanced-pool.js🆕 +5.76 kB0 B → 5.76 kB
node_modules/undici/lib/api/api-pipeline.js🆕 +5.68 kB0 B → 5.68 kB
node_modules/undici/lib/api/api-stream.js🆕 +5.5 kB0 B → 5.5 kB
node_modules/undici/index.js🆕 +5.21 kB0 B → 5.21 kB
node_modules/undici/lib/dispatcher/dispatcher-base.js🆕 +4.79 kB0 B → 4.79 kB
node_modules/undici/lib/dispatcher/pool-base.js🆕 +4.77 kB0 B → 4.77 kB
node_modules/undici/lib/dispatcher/env-http-proxy-agent.js🆕 +4.73 kB0 B → 4.73 kB
node_modules/undici/lib/mock/mock-agent.js🆕 +4.68 kB0 B → 4.68 kB
node_modules/undici/lib/web/cookies/index.js🆕 +4.43 kB0 B → 4.43 kB
node_modules/undici/lib/dispatcher/fixed-queue.js🆕 +4.37 kB0 B → 4.37 kB
node_modules/undici/lib/dispatcher/agent.js🆕 +4.11 kB0 B → 4.11 kB
node_modules/undici/lib/web/cache/cachestorage.js🆕 +3.87 kB0 B → 3.87 kB
node_modules/undici/lib/core/tree.js🆕 +3.65 kB0 B → 3.65 kB
node_modules/undici/lib/web/fetch/constants.js🆕 +3.6 kB0 B → 3.6 kB
node_modules/undici/lib/web/fetch/file.js🆕 +3.42 kB0 B → 3.42 kB
node_modules/undici/lib/dispatcher/pool.js🆕 +3.11 kB0 B → 3.11 kB
node_modules/undici/lib/core/constants.js🆕 +2.82 kB0 B → 2.82 kB
node_modules/srvx/dist/_chunks/response-Ca-wGejU.mjs🆕 +2.8 kB0 B → 2.8 kB
node_modules/undici/lib/api/api-upgrade.js🆕 +2.74 kB0 B → 2.74 kB
node_modules/undici/lib/api/api-connect.js🆕 +2.72 kB0 B → 2.72 kB
node_modules/undici/lib/core/symbols.js🆕 +2.71 kB0 B → 2.71 kB
node_modules/undici/lib/interceptor/dump.js🆕 +2.64 kB0 B → 2.64 kB
node_modules/undici/lib/api/util.js🆕 +2.53 kB0 B → 2.53 kB
src/dev/websocket.ts🆕 +2.52 kB0 B → 2.52 kB
node_modules/undici/lib/web/websocket/frame.js🆕 +2.47 kB0 B → 2.47 kB
node_modules/undici/lib/web/websocket/sender.js🆕 +2.44 kB0 B → 2.44 kB
node_modules/undici/lib/web/websocket/permessage-deflate.js🆕 +2.2 kB0 B → 2.2 kB
src/dev/fetch.ts🆕 +2.07 kB0 B → 2.07 kB
node_modules/undici/lib/web/fileapi/progressevent.js🆕 +1.85 kB0 B → 1.85 kB
node_modules/undici/lib/mock/mock-client.js🆕 +1.64 kB0 B → 1.64 kB
node_modules/undici/lib/mock/mock-pool.js🆕 +1.61 kB0 B → 1.61 kB
node_modules/undici/lib/dispatcher/dispatcher.js🆕 +1.61 kB0 B → 1.61 kB
node_modules/cookie-es/dist/index.mjs🆕 +1.49 kB0 B → 1.49 kB
node_modules/undici/lib/mock/pending-interceptors-formatter.js🆕 +1.46 kB0 B → 1.46 kB
node_modules/undici/lib/web/fetch/dispatcher-weakref.js🆕 +1.3 kB0 B → 1.3 kB
node_modules/undici/lib/web/websocket/constants.js🆕 +1.25 kB0 B → 1.25 kB
node_modules/undici/lib/api/abort-signal.js🆕 +1.25 kB0 B → 1.25 kB
node_modules/undici/lib/web/cache/util.js🆕 +1.13 kB0 B → 1.13 kB
node_modules/undici/lib/handler/decorator-handler.js🆕 +1.07 kB0 B → 1.07 kB
node_modules/undici/lib/web/fetch/global.js🆕 +1.04 kB0 B → 1.04 kB
node_modules/undici/lib/global.js🆕 +1002 B0 B → 1002 B
node_modules/undici/lib/mock/mock-symbols.js🆕 +954 B0 B → 954 B
node_modules/undici/lib/web/eventsource/util.js🆕 +929 B0 B → 929 B
node_modules/undici/lib/interceptor/redirect-interceptor.js🆕 +894 B0 B → 894 B
node_modules/undici/lib/dispatcher/retry-agent.js🆕 +856 B0 B → 856 B
node_modules/undici/lib/interceptor/redirect.js🆕 +737 B0 B → 737 B
node_modules/undici/lib/dispatcher/pool-stats.js🆕 +735 B0 B → 735 B
node_modules/undici/lib/mock/pluralizer.js🆕 +682 B0 B → 682 B
node_modules/undici/lib/mock/mock-errors.js🆕 +604 B0 B → 604 B
node_modules/undici/lib/interceptor/retry.js🆕 +539 B0 B → 539 B
node_modules/undici/lib/llhttp/utils.js🆕 +482 B0 B → 482 B
node_modules/undici/lib/web/cookies/constants.js🆕 +480 B0 B → 480 B
node_modules/undici/lib/web/fileapi/symbols.js🆕 +473 B0 B → 473 B
node_modules/undici/lib/web/websocket/symbols.js🆕 +472 B0 B → 472 B
node_modules/undici/lib/web/fetch/symbols.js🆕 +336 B0 B → 336 B
node_modules/undici/lib/api/index.js🆕 +295 B0 B → 295 B
View detailed bundle breakdown

Added

AssetFile Size% Changed
shared/nuxi.D6tXIntv.mjs0 B → 158.51 kB (+158.51 kB)-
shared/nuxi.Gg4oZG1J.mjs0 B → 128.29 kB (+128.29 kB)-
shared/nuxi.BVftAOL6.mjs0 B → 18.11 kB (+18.11 kB)-

Removed

AssetFile Size% Changed
shared/nuxi.CcH3VZ-h.mjs158.51 kB → 0 B (-158.51 kB)-100%
shared/nuxi.sAj5PmqJ.mjs128.28 kB → 0 B (-128.28 kB)-100%
shared/nuxi.B5WkReRs.mjs18.11 kB → 0 B (-18.11 kB)-100%

Bigger

AssetFile Size% Changed
chunks/dev.mjs28.45 kB → 938.2 kB (+909.75 kB)+3197.82%
chunks/init.mjs676.37 kB → 676.48 kB (+113 B)+0.02%
chunks/index5.mjs5.85 kB → 5.86 kB (+5 B)+0.08%

Smaller

No assets were smaller

Unchanged

AssetFile Size% Changed
index.mjs247 B0%
dev/index.mjs925 B0%
chunks/add.mjs6.89 kB0%
chunks/analyze.mjs3.35 kB0%
chunks/build.mjs2.07 kB0%
chunks/cleanup.mjs471 B0%
chunks/dev-child.mjs780 B0%
chunks/devtools.mjs764 B0%
chunks/generate.mjs492 B0%
chunks/info.mjs4.43 kB0%
chunks/index.mjs274 B0%
chunks/prepare.mjs1.05 kB0%
chunks/preview.mjs3.58 kB0%
chunks/test.mjs1.16 kB0%
chunks/typecheck.mjs2.06 kB0%
chunks/upgrade.mjs6.65 kB0%
chunks/satisfies.mjs116 B0%
chunks/main.mjs15.3 kB0%
chunks/prompt.mjs42.91 kB0%
chunks/index2.mjs199.56 kB0%
chunks/jiti.mjs498 B0%
chunks/index3.mjs71.97 kB0%
chunks/multipart-parser.mjs5.11 kB0%
chunks/add2.mjs12.1 kB0%
chunks/search.mjs45.85 kB0%
chunks/xdg-open.mjs25.32 kB0%
chunks/node.mjs145.67 kB0%
chunks/index4.mjs1.23 kB0%
chunks/index6.mjs904.13 kB0%
chunks/multipart-parser2.mjs4.58 kB0%
shared/nuxi.Bv-FePcy.mjs19.81 kB0%
shared/nuxi.DQjfoGl0.mjs57.22 kB0%
shared/nuxi.CTyTlDmo.mjs18.91 kB0%
shared/nuxi.C-cP1f7p.mjs1.71 kB0%
shared/nuxi.C_u-rG9b.mjs294 B0%
shared/nuxi.DUZ_WukQ.mjs2.57 kB0%
shared/nuxi.8mhVoXwa.mjs916.43 kB0%
shared/nuxi.D2_bzAv0.mjs1.54 kB0%
shared/nuxi.DQbQuzNE.mjs4.07 kB0%
shared/nuxi.BSm0_9Hr.mjs107 B0%
shared/nuxi.DkoVccfL.mjs10.64 kB0%
shared/nuxi.CrvQqJcE.mjs836 B0%
shared/nuxi.BiWTNJI4.mjs945 B0%
shared/nuxi.BAGoDD49.mjs1.05 kB0%
shared/nuxi.BjhZEm2-.mjs1.75 kB0%
shared/nuxi.QWnQy_ku.mjs5.75 kB0%
shared/nuxi.DlMb1OKt.mjs365 B0%
shared/nuxi.DU9QXUOf.mjs26.96 kB0%
shared/nuxi.8uLzFmy0.mjs14.73 kB0%
shared/nuxi.BLb4POFS.mjs42.47 kB0%
shared/nuxi.Do0aYBCO.mjs5.46 kB0%
shared/nuxi.4t9faemh.mjs43.64 kB0%

@github-actions

github-actionsBot commented Sep 24, 2025

Copy link
Copy Markdown
Contributor

Bundle Stats — nuxt-cli size comparison

Hey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle.

As this PR is updated, I'll keep you updated on how the bundle size is impacted.

Total

Files countTotal bundle size% Changed
3198.78 kB → 103.33 kB (+4.55 kB)+4.61%
Changeset
FileΔSize
home/runner/work/cli/cli/packages/nuxi/src/dev/websocket.ts🆕 +2.52 kB0 B → 2.52 kB
home/runner/work/cli/cli/packages/nuxi/src/dev/fetch.ts🆕 +2.05 kB0 B → 2.05 kB
home/runner/work/cli/cli/packages/nuxi/src/commands/dev.ts📉 -17 B (-0.15%)11.31 kB → 11.29 kB
View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

AssetFile Size% Changed
chunks/dev.mjs11.31 kB → 15.86 kB (+4.55 kB)+40.25%

Smaller

No assets were smaller

Unchanged

AssetFile Size% Changed
dev/index.mjs0 B0%
index.mjs236 B0%
chunks/index.mjs14.49 kB0%
chunks/analyze.mjs3.35 kB0%
chunks/cleanup.mjs471 B0%
chunks/dev-child.mjs815 B0%
chunks/devtools.mjs763 B0%
chunks/generate.mjs492 B0%
chunks/build.mjs2.07 kB0%
chunks/index2.mjs308 B0%
chunks/add.mjs11.25 kB0%
chunks/search.mjs2.96 kB0%
chunks/preview.mjs3.58 kB0%
chunks/test.mjs1.16 kB0%
chunks/typecheck.mjs2.06 kB0%
chunks/upgrade.mjs6.65 kB0%
chunks/prepare.mjs1.05 kB0%
chunks/info.mjs4.46 kB0%
chunks/init.mjs12.75 kB0%
chunks/add2.mjs6.89 kB0%
shared/cli.B9AmABr3.mjs39 B0%
shared/cli.CehBW0fN.mjs1.71 kB0%
shared/cli.BEUGgaW4.mjs294 B0%
shared/cli.BSm0_9Hr.mjs107 B0%
shared/cli.At9IMXtr.mjs1.23 kB0%
shared/cli.pLQ0oPGc.mjs836 B0%
shared/cli.qKvs7FJ2.mjs945 B0%
shared/cli.Cr-OCgdO.mjs727 B0%
shared/cli.DHenkA1C.mjs351 B0%
shared/cli.DVoN1ieL.mjs5.57 kB0%

@pkg-pr-new

pkg-pr-newBot commented Sep 24, 2025

Copy link
Copy Markdown

nuxt-cli-playground

npm i https://pkg.pr.new/create-nuxt@1051
npm i https://pkg.pr.new/nuxi@1051
npm i https://pkg.pr.new/@nuxt/cli@1051

commit: 9f5a5b7

@codspeed-hq

codspeed-hqBot commented Sep 24, 2025

Copy link
Copy Markdown

CodSpeed Performance Report

Merging #1051 will not alter performance

Comparing feat/socket-fetch (9f5a5b7) with main (f4749f8)

Summary

✅ 2 untouched

@danielroe
danielroe marked this pull request as ready for review September 24, 2025 11:11
Comment threadpackages/nuxi/src/dev/fetch.ts Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could port it to crossws (/node) as Nitro needs this too.

* Fetch to a specific address (socket or network)
* Based on Nitro's fetchAddress implementation
*/
function fetchAddress(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we have this at least 3 places now (twice in Nitro and here), this could be maintained single place upstream...

@danielroe
danielroe merged commit bc4b293 into mainSep 26, 2025
15 checks passed
@danielroe
danielroe deleted the feat/socket-fetch branch September 26, 2025 12:07
@github-actionsgithub-actionsBot mentioned this pull request Sep 26, 2025
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@danielroe@pi0