Files
Arcrun/system-dev/wiki/cards/decisions/same-zone-1042用flag解不用binding.md
uncle6me-web 558e80b4da chore(wiki): wiki-init 補骨架 + system-dev-template 安裝/更新腳本
wiki 已初始化過(push 檔活躍維護),本次補從沒建的 pull 層 + arcrun 化範本:
- cards/decisions/ 14 張決策原子卡(含 gloss/實體/typed-edge 三元組):
  從 decisions-summary 全量改寫 13 + 新增「薄殼規則晚於實作-MCP漂移是歷史債」1
- TAXONOMY 從 PKM 範本換成 arcrun 軸(子系統 零件架構/cypher/credential/recipe/kbdb/
  薄殼/部署/平台原則 + 形態 架構決策/踩坑/機制說明/禁令/案例經驗)
- principles 填 13 條跨全局原則(從 rules/ + mindset 蒸餾)
- INDEX 真實視圖(子系統角度 + 決策角度,指向 cards)
- system-dev/scripts/ + scripts/ install/update 安裝腳本(template 接入)

純基建/文檔,無業務 code(功能 code 見前一 commit)。
raw source(docs/)0 異動、wiki 卡際連結無斷鏈。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-27 17:53:37 +08:00

38 lines
2.8 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
tags: [cypher, 部署, 架構決策, 踩坑]
gloss: self-hosted cypher 和 component 同在 workers.dev zone 觸發 CF 1042,用 global_fetch_strictly_public flag 解,不是 Service Binding。
---
# Same-Zone 1042 用 flag 解不用 Binding
← [[decisions/00-INDEX]]
**來源**`system-dev/wiki/decisions-summary.md`(Cypher 怎麼調用零件避開 same-zone 1042)、`docs/incidents/2026-05-13-cypher-outbound-522.md`
**最後更新**2026-06-27
## 摘要
Cloudflare Workers 的 same-zone fetch 防護(HTTP 522)在 self-hosted 部署中會踩坑,因為 cypher 和 component 都在 `{sub}.workers.dev`。解法是在 cypher-executor 的 wrangler.toml 加 `global_fetch_strictly_public` flag,讓 same-zone fetch 走公網前門——而非用 Service Binding(那樣更死)。
## 重點
- **官方部署無此問題**:cypher 在 `cypher.arcrun.dev`、component 在 `*.arcrun.dev``arcrun-*.workers.dev`,跨 zone,不踩防護。
- **Self-hosted 部署踩坑**:都在 `{sub}.workers.dev`,CF 防止同 zone 自循環死鎖,cypher fetch component 返 522。
- **為什麼不用 Service Binding**Binding 靜態、修改要 redeploycomponent 清單動態(用戶 workflow 決定),改變架構必要性低;flag 無副作用(official 加也沒影響,本就跨 zone)。
- **Flag 部署法**`cypher-executor/wrangler.toml` 加一行 `compatibility_flags = [ "nodejs_compat", "global_fetch_strictly_public" ]`,然後 cypher 和 auth worker 間的 HTTP fetch 都能通。
- **驗證**:若仍 522 → 檢查 flag 是否生效(某些 Wrangler 版本可能有 bug)。
## 實體
- **Same-zone 防護**Cloudflare same-zone protection)— CF Workers 內建的防護機制,禁止 Worker 在同一 zone 內 fetch 另一個 Worker 以防自循環。
- **HTTP 522**522 Connection Timed Out)— Cloudflare 自有錯誤,表示 fetch 因防護被擋。
- **global_fetch_strictly_public flag**Cloudflare compatibility flag)— 讓 same-zone fetch 從內部網路改走公網前門的相容旗標,無副作用。
- **cypher-executor**Cypher 執行引擎)— 調度 workflow 並呼叫零件的 Worker,需加 flag 才能在 self-hosted fetch component。
- **動態 component 清單**dynamic component list)— workflow 執行時的零件集合,由用戶定義、會變動,無法靜態綁定。
## 關聯
### 內文知識關係
- same-zone 防護 >> 在 self-hosted >> 觸發 HTTP 522
- global_fetch_strictly_public flag >> 解決 >> HTTP 522
- global_fetch_strictly_public flag >> 不改變 >> 官方部署
- Service Binding >> 不能解決 >> 動態 component 清單
### 卡片關係
- [[same-zone-1042用flag解不用binding]] >> 迴避 >> [[service-binding-vs-cypher-binding]]
- [[same-zone-1042用flag解不用binding]] >> 涉及事件 >> [docs/incidents/2026-05-13-cypher-outbound-522.md]