Repository navigation
[withdrawn] browser-use-stagehand-native: worker-client.ts passes env: {} to new Worker — on Windows the worker's os.tmpdir() degrades to the relative path undefined\temp; the src-mode tsx cache lands in a literal undefined/ directory under the process CWD #8222
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Defect E —
browser-use-stagehand-nativestarts its Worker withenv: {}; on Windowsos.tmpdir()inside the worker degrades to the relative pathundefined\temp, so tsx cache (and any temp writes) land in a literalundefined/directory under the process CWDTitle (issue/discussion-ready)
browser-use-stagehand-native:worker-client.tspassesenv: {}tonew Worker— on Windows the worker'sos.tmpdir()degrades to the relative pathundefined\temp; the src-mode tsx cache lands in a literalundefined/directory under the process CWDVersion affected
dsh-v0.1.7-rc.2(tag477b4f4205); the file is byte-identical in our downstream tree (git diff 477b4f4205..HEAD -- packages/experimental/browser-use-stagehand-native/src/worker-client.ts→ empty). [ops re-verified 2026-09-29]const env: NodeJS.ProcessEnv = {}construction; no post-rc.2 commits touched this package except the 0.2.0-rc.1 release bump. [ops live check 2026-09-29]env: {}isolation design was introduced; the report targets the code as it stands at rc.2 and master.Summary
worker-client.ts(openBrowserWorker, consumed viasrc/index.ts:106) deliberately starts the Stagehand worker with an empty environment — line 20 comment: "Only explicit model credentials cross in workerData; ambient credentials and proxy settings stay outside." — passing through onlyTSX_TSCONFIG_PATHwhen set:On Windows, a worker thread with an empty
envhas noTEMP,TMP, orSystemRoot. Node'sos.tmpdir()win32 fallback then produces`${process.env.SystemRoot}\temp`→ the relative pathundefined\temp. The src-mode branch (line 29–30) bootstraps tsx inside that worker; tsx puts its cache underos.tmpdir(), so with CWD = repository root the cache is written to<repo>\undefined\temp\tsx-<user>\...— a junk directory that pollutes the working tree, breaks clean-tree checks, and escapes any expectation that temp files live in the OS temp directory. On POSIX the same code degrades to the documented/tmpfallback, so the visible damage is win32-specific (inference from Node's documented fallback behavior; not probed on POSIX).Reproduction
Minimal probe, Windows 10.0.26200, Node v24.19.0 — replicates the exact
env: {}worker construction ofworker-client.ts:21-26:Observed output (run 2026-09-29, retained at
G:\000Github\zDSH\zDSH-docs\TMP\pub2-probe\probe-env-empty.log):End-to-end trace (real runs): after executing src-mode test suites with CWD = repository root, the tree contains
Evidence
worker-client.ts:21-31quoted verbatim above;git diff 477b4f4205..HEADon the file is empty. [ops re-verified 2026-09-29]env: {}construction. [ops live check 2026-09-29]env:{}worker on win32 →"undefined\\temp"with TEMP/TMP/SystemRoot all null. [ops live probe 2026-09-29, Node v24.19.0, Windows 10.0.26200; matches the probe recorded during our P3-CFIX task ({"tmpdir":"undefined\\temp"})]undefined\temp\tsx-ZS\17906-<sha1>×5 entries at our repository root [ops re-verified 2026-09-29 by directory listing]; independently observed during our compat diagnosis on 2026-09-29 as an unexplained untrackedundefined/directory ("某脚本 mkdir undefined 类 bug 痕迹",P3-compat-diagnosis.md§4-U3). Thetsx-ZScache path names tsx (bootstrapped in-worker by line 29–30) as the writer.src/index.ts:106callsopenBrowserWorker(the only production entry to this worker construction). [ops re-verified 2026-09-29]Expected vs Actual
os.tmpdir()inside the worker should return an absolute, usable temp directory, and tooling caches (tsx) should land there.os.tmpdir()return the relative junk pathundefined\temp; tsx then createsundefined/temp/tsx-<user>/under whatever the process CWD is (repository root in dev/test), polluting the working tree and writing outside any temp-directory expectation.Suggested fix
Pick one (option 1 keeps the isolation intent intact):
TEMP,TMP,SystemRoot(all three:SystemRootalso matters for general Win32 API behavior in the worker); on POSIX:TMPDIR. Credentials and proxy variables stay excluded, preserving the documented isolation design.TSX_CACHE_DIRexplicitly (and any other SDK temp-dir knobs) from the host to an absolute path — e.g. derived from the host's ownos.tmpdir()— passed throughenvalongsideTSX_TSCONFIG_PATH.os.tmpdir().Workaround (downstream, applied)
We added
undefined/to our.gitignore(commit473c778757, 2026-09-29) to keep clean-tree checks green. This masks the symptom only — the cache still lands in the CWD, and any downstream without that ignore line sees a polluted working tree. Not a fix.All reactions