Skip to content

test(sdk-ts): make setInputFiles historical-mtime expectation portable to Windows - #3524

Open
DZH166 wants to merge 1 commit into
browserbase:mainfrom
DZH166:codex/objectwrapper-pre-epoch-mtime-win-20261122
Open

DZH166 wants to merge 1 commit into
browserbase:mainfrom
DZH166:codex/objectwrapper-pre-epoch-mtime-win-20261122

Conversation

@DZH166

@DZH166 DZH166 commented Nov 21, 2026 •

Copy link
Copy Markdown

Summary

The sdk-ts test packages/sdk-ts/tests/objectWrapper.test.ts > normalizes files and payloads and routes locator.setInputFiles fails on Windows hosts at current main.

The test writes historical.txt and sets a pre-epoch mtime with utimes(path, new Date(0), new Date(-1_000)), expecting the upload payload to omit lastModified (the SDK's nodeBrowserApiPlatform.readInputFile omits the field when the reported mtime is negative — a correct guard, not the thing being fixed here). On Windows that fixture cannot exist: libuv's utimes wraps pre-epoch seconds through an unsigned 32-bit conversion, so a file given mtime = -1000 ms reports mtimeMs = 4294967295000 (~2106-02-07) back through fs.stat. The upload therefore carries a positive lastModified and the strict toStrictEqual fails:

- Expected
+ Received
  files: [
    {
      "data": "b2xk",
+     "lastModified": 4294967295000,
      "name": "historical.txt",

The production code is already correct on both platforms — the omission branch simply cannot be exercised through a real filesystem on Windows. So this is a test-side portability fix, in the same spirit as #3458 (this exact failure was also catalogued as pre-existing on Windows in the validation notes of that PR).

The change derives the expected payload from what the filesystem actually reports, keeping the test green and meaningful everywhere:

  • on POSIX (CI), stat reports the negative mtime, so the expectation remains files: [{ name, data }] — the pre-epoch omission branch stays covered;
  • on Windows, the expectation becomes lastModified: <reported mtimeMs> — which additionally covers the positive-mtime passthrough for path uploads, previously untested.

No production code changes, no changeset (CONTRIBUTING.md: tests do not need a Changeset).

Validation

All on a Windows 11 host (the affected platform), at base 3bedd82 (current main):

  • packages/sdk-ts/tests/objectWrapper.test.ts before the change: 102 passed / 1 failed (... routes locator.setInputFiles, AssertionError ... "lastModified": 4294967295000 vs omitted, test line 2222). After the change: 103/103 pass. Red/green logs attached to the contribution package.
  • Full sdk-ts unit suite: 651 passed / 12 failed at base → 652 passed / 11 failed with this change. The failure-set diff is exactly the objectWrapper test above; the remaining 11 are pre-existing on Windows and unrelated: 5 in factories.test.ts (addressed by open test(sdk-ts): make factories extension path assertions portable to Windows #3458), 1 in localBrowser.test.ts (addressed by open fix(sdk-ts): build Linux Chrome candidates with POSIX path semantics on every host #3506), 1 in browserbaseTransport.test.ts (undici cross-test timer pollution, previously diagnosed), 1 in packageContract.test.ts (spawn pnpm ENOENT for .cmd shims), and 3 new cdpClient.test.ts service-worker symlink cases from fix(sdk): replace a service worker left over from a different extension build #3502 that require symlink privileges on Windows.
  • node:fs/promises round-trip probe confirming the platform behavior: utimes(f, new Date(0), new Date(-1000)) then stat → mtimeMs === 4294967295000 on Windows.
  • oxfmt --check — clean; oxlint — 0 errors (9 pre-existing no-deprecated warnings on untouched lines); tsc --noEmit -p packages/sdk-ts — clean; git diff --check — clean.

AI assistance

Prepared with an AI coding agent (ZCode) from a maintainer-diagnosed failure; the analysis, fix, and validation were verified locally as described above.


Summary by cubic

Fixes the sdk-ts setInputFiles test so it passes on Windows as well as POSIX.

The test writes a file with a pre-epoch mtime and expects the upload payload to omit lastModified. On Windows, libuv wraps pre-epoch mtimes into positive values, so the filesystem reports a positive mtime and the strict assertion fails.

The expected payload is now derived from what stat actually reports instead of being hardcoded:

  • POSIX keeps reporting the negative mtime, so the pre-epoch omission branch stays covered.
  • Windows now asserts the wrapped positive mtime, which also covers positive-mtime passthrough.

No production code changes.

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

View guided diff

@changeset-bot

changeset-bot Bot commented Nov 21, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: bf05e16

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a 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 Nov 21, 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