Windows: start fails because daemon path comes from URL.pathname

未關閉 適合新手
#64 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
82/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
node.js, typescript
領域
cli

研究方向

從 packages/agent-react-devtools/src/daemon-client.ts 中 daemon 路徑的建構和過期檢查開始,接著檢查 packages/agent-react-devtools/src/daemon.ts 中的 buildMtime 統計資料。查看 CLI 如何根據 import.meta.url 推導路徑,包括 Windows 磁碟機代號和編碼後的空格;issue 指出 fileURLToPath 是預期的轉換方式。完成標準是 daemon 指令碼路徑在 Windows 上有效,且能安裝到包含空格的路徑下。

由索引模型根據 Issue 內容生成。

描述

Summary

On Windows, start always fails with Daemon failed to start within 5 seconds. The CLI builds the daemon script path from new URL(import.meta.url).pathname, which is not a valid file path on Windows.

Environment

  • agent-react-devtools 0.5.0 (same code on main @ d25f34b)
  • Node 26.8.1
  • Windows 11 (10.0.26100)

Repro

> agent-react-devtools start --port 8098
Daemon failed to start within 5 seconds

The spawned daemon exits at once. Running the same spawn by hand shows why:

script: \D:\temp\ard\node_modules\agent-react-devtools\dist\daemon.js
Error: Cannot find module 'D:\D:\temp\ard\node_modules\agent-react-devtools\dist\daemon.js'

Cause

new URL('file:///D:/x/cli.js').pathname is /D:/x/cli.js. After path.join it becomes \D:\x\... (leading backslash), which Node resolves to D:\D:\x\.... pathname also keeps percent-encoding, so an install under a path with spaces breaks on any OS:

url:           file:///C:/Program%20Files/nodejs/node_modules/agent-react-devtools/dist/cli.js
pathname:      \C:\Program%20Files\nodejs\node_modules\agent-react-devtools\dist\daemon.js
fileURLToPath: C:\Program Files\nodejs\node_modules\agent-react-devtools\dist\daemon.js

Locations:

Fix

Use fileURLToPath(import.meta.url) from node:url. With that change the daemon spawns on Windows, but it then fails on the IPC socket (https://github.com/callstackincubator/agent-react-devtools/issues/65).

主要語言
TypeScript
星號
251
分支
13
PR 合併指標
30 天內沒有已合併 PR

環境準備

這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

callstackincubator/agent-react-devtools 的其他 Issue

查看 callstackincubator/agent-react-devtools 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。