CLI HTTP client ignores NO_PROXY, so emulators can’t reach each other behind a proxy
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 74/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- nodejs, typescript
- Lĩnh vực
- cli, networking
Hướng nghiên cứu
Client HTTP nằm trong src/apiv2.ts (được biên dịch thành lib/apiv2.js), nơi dispatcher của proxy được tạo từ HTTPS_PROXY mà không kiểm tra NO_PROXY. Hãy đọc cách dispatcher này được gắn vào các tùy chọn fetch, sau đó tái hiện lỗi theo các bước trong issue bằng một địa chỉ proxy từ chối kết nối. Hoàn thành khi các yêu cầu tới 127.0.0.1 bỏ qua proxy, trigger của emulator được đăng ký và script chạy được. Việc thay agent undici mà người báo lỗi đề xuất là điểm khởi đầu, nhưng sự đánh đổi với cảnh báo experimental cần ý kiến của maintainer.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
[REQUIRED] Environment info
firebase-tools: 15.33.0 (also reproduced on 15.32.1)
Platform: Ubuntu 24.04.5 LTS (x86_64), Node.js 24.21.0
[REQUIRED] Test case
When HTTPS_PROXY is set, the CLI's HTTP client (lib/apiv2.js) sends every request through new undici.ProxyAgent({ uri: proxyURI }) and never checks NO_PROXY / no_proxy. Requests between emulators on 127.0.0.1 therefore go to the proxy too. The Functions emulator then can't register Firestore triggers with the Firestore emulator, and emulators:start / emulators:exec fail.
This affects anyone running the emulators behind a corporate or sandbox proxy, even with NO_PROXY=localhost,127.0.0.1. #4637 and #4386 describe similar symptoms on older versions.
Minimal project:
firebase.json
{
"functions": [{ "source": "functions" }],
"emulators": {
"firestore": { "port": 8080 },
"functions": { "port": 5001 },
"ui": { "enabled": false },
"singleProjectMode": true
}
}
functions/package.json
{
"name": "functions",
"main": "index.js",
"engines": { "node": "24" },
"dependencies": {
"firebase-admin": "^14.4.0",
"firebase-functions": "^7.0.0"
}
}
functions/index.js
const { onDocumentUpdated } = require('firebase-functions/firestore')
exports.onUserUpdated = onDocumentUpdated('users/{userId}', (event) => {
console.log('updated', event.params.userId)
})
[REQUIRED] Steps to reproduce
- Create the files above and run
npm installinfunctions/. - Point the proxy variables at any proxy that can't reach localhost. A port with nothing listening is enough to reproduce:
export HTTPS_PROXY=http://127.0.0.1:9 export NO_PROXY=localhost,127.0.0.1 - Run:
firebase emulators:exec --debug --project demo-repro --only firestore,functions "echo SCRIPT RAN"
[REQUIRED] Expected behavior
Hosts listed in NO_PROXY are connected to directly, as in other Node and CLI tools. The Functions emulator registers the trigger with the local Firestore emulator, and the script runs:
✔ functions[us-central1-onUserUpdated]: firestore function initialized.
i Running script: echo SCRIPT RAN
SCRIPT RAN
✔ Script exited successfully (code 0)
[REQUIRED] Actual behavior
The request to the local Firestore emulator is sent to the proxy, so trigger registration fails:
>>> [apiv2][query] POST http://127.0.0.1:8080/emulator/v1/projects/demo-repro/eventarcTrigger?eventarcTriggerId=us-central1-onUserUpdated-0 [none]
*** [apiv2] error from fetch(http://127.0.0.1:8080/emulator/v1/projects/demo-repro/eventarcTrigger?eventarcTriggerId=us-central1-onUserUpdated-0, {"headers":{},"method":"POST","dispatcher":{...}}): Error: connect ECONNREFUSED 127.0.0.1:9
⚠ Error adding firestore function: FirebaseError: Failed to make request to http://127.0.0.1:8080/emulator/v1/projects/demo-repro/eventarcTrigger?eventarcTriggerId=us-central1-onUserUpdated-0
Error: Failed to make request to http://127.0.0.1:8080/emulator/v1/projects/demo-repro/eventarcTrigger?eventarcTriggerId=us-central1-onUserUpdated-0
ECONNREFUSED 127.0.0.1:9 is the proxy address, not the emulator. Behind a real proxy that rejects localhost, the proxy's error page comes back instead, and the emulator fails with Unable to parse JSON: SyntaxError: Unexpected token 'r', "request bl"... is not valid JSON.
Suggested fix: in lib/apiv2.js (src/apiv2.ts), use undici's EnvHttpProxyAgent, which applies NO_PROXY, with the same proxy URL:
fetchOptions.dispatcher = new undici.EnvHttpProxyAgent({ httpProxy: proxyURI, httpsProxy: proxyURI });
With only this change, the same repro passes (output under "Expected behavior"). We've used it as a local patch, and our full emulator-based E2E suite passes behind a proxy. undici 6 prints an "EnvHttpProxyAgent is experimental" warning. Happy to open a PR if that approach works for you.
- Ngôn ngữ chính
- TypeScript
- Star
- 4.5k
- Fork
- 1.3k
- Merge trung bình
- 3 ngày 7 giờ
- Pull request đã merge (30 ngày)
- 96
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của firebase/firebase-tools
-
Nodejs26 rejected at deploy, though Cloud Run functions supports it (Preview)Có thể đã có người làm @IzaakGough đã nhận 11 ngày trước. Đang mởapi: functions reproducible type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
firebase/firebase-tools#11393 · 2 bình luận · 4 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[firebase-vscode] CLI version check reads the version from the debug banner, because logSetup() leaks DEBUG=true into the spawned `firebase --version` (follow-up to #10874)Có thể đã có người làm @abhiramshaji-cyber đã nhận 13 ngày trước. Đang mởreproducible type: bug VSCode Extension
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
firebase/firebase-tools#11363 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[MCP] Crashlytics tools not loaded for Android projects using Gradle version catalogs (libs.versions.toml)Có thể đã có người làm @aalej đã nhận 13 ngày trước. Đang mởapi: mcp reproducible type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
firebase/firebase-tools#11351 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
functions:secrets:set and :prune never destroy anything: pruneSecrets filters firebase-managed=true, but labels() writes firebase-managed=functionsCó thể đã có người làm @IzaakGough đã nhận 62 ngày trước. Đang mởapi: functions reproducible type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
firebase/firebase-tools#11066 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Emulator hangs trying to get credentials from cloud with demo serverCó thể đã có người làm @kevmoo đã nhận 203 ngày trước. Đang mởemulators: functions type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
firebase/firebase-tools#10398 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của firebase/firebase-tools
Issue tương tự
-
area:tooling good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
interledger/publisher-tools#1007 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
priority/medium roadmap/v1.1.1 stakeholder/rapr type/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
databrickslabs/ontos#1420 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
vercel-labs/just-bash#756 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area: ci good first issue
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
interledger/web-monetization-extension#1555 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[t-dialog] 弹窗组件和抽屉组件的文档说明不够详细清楚Đang mở🐞 bug 🧐 unconfirmed
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Tencent/tdesign-vue-next#7056 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày