Skip to content

fix(sdk-ts): reject FIFO uploads without blocking - #3355

Open
Elon-Jiang wants to merge 1 commit into
browserbase:mainfrom
Elon-Jiang:fix/ts-file-upload-fifo
Open

Elon-Jiang wants to merge 1 commit into
browserbase:mainfrom
Elon-Jiang:fix/ts-file-upload-fifo

Conversation

@Elon-Jiang

@Elon-Jiang Elon-Jiang commented Oct 30, 2026 •

Copy link
Copy Markdown

why

Locator.setInputFiles(path) opens a path before checking the descriptor's file type. On POSIX, opening a FIFO for reading waits for a writer, so a FIFO (or a symlink to one) can hang the upload before the existing non-file rejection is reached. No browser RPC is sent.

Reproduction on macOS with a FIFO that has no writer:

import { execFileSync } from "node:child_process";
import { mkdtemp, rm } from "node:fs/promises";
import { tmpdir } from "node:os";
import path from "node:path";

const directory = await mkdtemp(path.join(tmpdir(), "stagehand-fifo-"));
const fifo = path.join(directory, "upload.pipe");
execFileSync("mkfifo", [fifo]);
try {
  await page.locator("input[type=file]").setInputFiles(fifo);
} finally {
  await rm(directory, { recursive: true, force: true });
}

Before: waits for a writer. After: rejects with the existing TypeError("setInputFiles(): expected a file") without waiting. The Python SDK already handles this case (see #2559); this fixes the TypeScript path.

what changed

  • Open local paths with O_RDONLY | O_NONBLOCK (falling back to 0 when the nonblocking flag is unavailable), then retain the descriptor's existing isFile() check and cleanup. Regular-file reads and upload-size limits are unchanged.
  • Add public Page.locator().setInputFiles() regressions for a real FIFO and a symlink to it. The tests verify rejection before any RPC and unblock the old implementation during cleanup, so a regression does not leave a blocked filesystem worker behind. FIFO tests are skipped on Windows.
  • Add a patch changeset for the TypeScript SDK.

test plan

Local checks on macOS arm64; pnpm 11.11.0 uses Node 24.22.1:

  • Both new regressions fail against unmodified b7a4b899 (blocked after 1 second); the full object-wrapper file passes 91 tests with the fix.
  • Full TypeScript SDK unit suite: 621 passed, 1 failed. The sole failure is packageContract.test.ts at its temporary consumer's pnpm exec tsc ... verify.ts step. It also fails at the same step in a clean, detached b7a4b899 worktree after rebuilding that unmodified SDK; it is not reported as passing here.
  • Whole-workspace pnpm build passed. pnpm check passed all 49 tasks (format, lint and types). Changeset/changelog/version checks passed.
  • Independent Node process importing the built SDK: FIFO, symlink-to-FIFO and directory rejected without RPC; normal file, normal-file symlink and in-memory payload uploaded the expected bytes. Strict unhandled-rejection handling enabled.
  • Real local headless-browser file-upload/clear integration passed with the repository's stub model, including a final run in the recommended Node environment. No cloud browser or paid model was used.
  • Existing Python SDK suite: 1096 passed, 10 skipped, with loopback addresses bypassing the local proxy. Python ruff, format, ty, lock and generated-model checks passed.

The full monorepo test/evaluation suite and Linux/Windows execution were not run locally. No claim of merge or upstream CI approval.

AI assistance: OpenAI Codex assisted with source inspection, reproduction, implementation and validation. The prior Python FIFO fix in #2559 provided useful cross-SDK context.


Summary by cubic

Fixes setInputFiles blocking indefinitely when the path points to a FIFO (or symlink to one) on POSIX. Local paths are now opened with O_NONBLOCK before the file-type check, so the existing TypeError("setInputFiles(): expected a file") rejection fires without waiting. Regular file uploads are unaffected. Adds regressions for direct and symlinked FIFOs (skipped on Windows) and a patch changeset.

Written for commit fa90e9e. Summary will update on new commits.

View guided diff

@changeset-bot

changeset-bot Bot commented Oct 30, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: fa90e9e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 21 packages
Name Type
@browserbasehq/stagehand Patch
browse Patch
@browserbasehq/stagehand-examples Patch
@browserbasehq/stagehand-integrations-claude-cua-sdk Patch
@browserbasehq/stagehand-integrations Patch
@browserbasehq/eve Patch
@browserbasehq/stagehand-integrations-gemini-cua-sdk Patch
@browserbasehq/stagehand-integrations-example-pi-facade Patch
@browserbasehq/stagehand-integrations-claude-agent-sdk Patch
@browserbasehq/stagehand-integrations-example-claude-code-facade Patch
@browserbasehq/stagehand-integrations-codex-sdk Patch
@browserbasehq/stagehand-integrations-example-codex-facade Patch
@browserbasehq/stagehand-integrations-cursor-sdk Patch
@browserbasehq/stagehand-integrations-example-cursor-facade Patch
@browserbasehq/stagehand-integrations-deepagents-sdk Patch
@browserbasehq/stagehand-integrations-eve-sdk Patch
@browserbasehq/stagehand-integrations-fx-sdk Patch
@browserbasehq/stagehand-integrations-mastra-sdk Patch
@browserbasehq/stagehand-integrations-example-mastra-facade Patch
@browserbasehq/stagehand-integrations-pi-sdk Patch
@browserbasehq/stagehand-integrations-example-vercel-ai-facade Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

Copy link
Copy Markdown
Contributor

This PR is from an external contributor and must be approved by a stagehand team member with write access before CI can run.
Approving the latest commit mirrors it into an internal PR owned by the approver.
If new commits are pushed later, the internal PR stays open but is marked stale until someone approves the latest external commit and refreshes it.

@github-actions github-actions Bot added external-contributor Tracks PRs mirrored from external contributor forks. external-contributor:awaiting-approval Waiting for a stagehand team member to approve the latest external commit. labels Oct 30, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external-contributor:awaiting-approval Waiting for a stagehand team member to approve the latest external commit. external-contributor Tracks PRs mirrored from external contributor forks.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant