You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
test(sdk-ts): make setInputFiles historical-mtime expectation portable to Windows - #3524
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:
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.
node:fs/promises round-trip probe confirming the platform behavior: utimes(f, new Date(0), new Date(-1000)) then stat → mtimeMs === 4294967295000 on Windows.
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-tssetInputFiles 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.
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
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The sdk-ts test
packages/sdk-ts/tests/objectWrapper.test.ts > normalizes files and payloads and routes locator.setInputFilesfails on Windows hosts at currentmain.The test writes
historical.txtand sets a pre-epoch mtime withutimes(path, new Date(0), new Date(-1_000)), expecting the upload payload to omitlastModified(the SDK'snodeBrowserApiPlatform.readInputFileomits the field when the reported mtime is negative — a correct guard, not the thing being fixed here). On Windows that fixture cannot exist: libuv'sutimeswraps pre-epoch seconds through an unsigned 32-bit conversion, so a file givenmtime = -1000 msreportsmtimeMs = 4294967295000(~2106-02-07) back throughfs.stat. The upload therefore carries a positivelastModifiedand the stricttoStrictEqualfails: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:
statreports the negative mtime, so the expectation remainsfiles: [{ name, data }]— the pre-epoch omission branch stays covered;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(currentmain):packages/sdk-ts/tests/objectWrapper.test.tsbefore the change: 102 passed / 1 failed (... routes locator.setInputFiles,AssertionError ... "lastModified": 4294967295000vs omitted, test line 2222). After the change: 103/103 pass. Red/green logs attached to the contribution package.sdk-tsunit 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 infactories.test.ts(addressed by open test(sdk-ts): make factories extension path assertions portable to Windows #3458), 1 inlocalBrowser.test.ts(addressed by open fix(sdk-ts): build Linux Chrome candidates with POSIX path semantics on every host #3506), 1 inbrowserbaseTransport.test.ts(undici cross-test timer pollution, previously diagnosed), 1 inpackageContract.test.ts(spawn pnpmENOENT for.cmdshims), and 3 newcdpClient.test.tsservice-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/promisesround-trip probe confirming the platform behavior:utimes(f, new Date(0), new Date(-1000))thenstat→mtimeMs === 4294967295000on Windows.oxfmt --check— clean;oxlint— 0 errors (9 pre-existingno-deprecatedwarnings 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-tssetInputFilestest 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
statactually reports instead of being hardcoded:No production code changes.
Written for commit bf05e16. Summary will update on new commits.