Skip to content

fix(files): use a monotonic clock for processing timeout - #2657

Open
mukeshr06 wants to merge 2 commits into
openai:mainfrom
mukeshr06:fix/file-processing-monotonic-timeout
Open

fix(files): use a monotonic clock for processing timeout#2657
mukeshr06 wants to merge 2 commits into
openai:mainfrom
mukeshr06:fix/file-processing-monotonic-timeout

Conversation

@mukeshr06

Copy link
Copy Markdown
  • I understand that this repository is auto-generated and my pull request may not be merged

Changes being requested

files.waitForProcessing() measures maxWait with Date.now(). A system clock correction can therefore cause a premature timeout or allow a response after the elapsed-time budget.

Use performance.now() in the handwritten src/lib/file-processing.ts helper to measure elapsed time. Preserve the existing polling interval, terminal statuses, initially terminal response behavior, and strict > timeout check after retrieval.

Add public-client regression cases for forward and backward clock corrections, and update the existing elapsed-time mocks. Both new cases fail with the previous implementation and pass with this change. No generated SDK files or dependencies change.

Additional context & links

Validation on Node.js 24.19.0:

  • ./scripts/test tests/lib/file-processing.test.ts: 18 passed.
  • ./scripts/lint: passed.
  • ./node_modules/.bin/tsc: passed.
  • ./scripts/build: passed.
  • ./scripts/test: all 7,751 handwritten tests passed. Generated tests could not start locally because the pinned Steady installation failed while fetching the @std/cli manifest from JSR.
  • git diff --check: passed.

AI assistance: Codex was used to prepare and test this patch.

@mukeshr06
mukeshr06 requested a review from a team as a code owner September 6, 2026 07:38
gh-actions-shared Bot pushed a commit to xf-qubit/openai-node that referenced this pull request Sep 6, 2026
## Summary

- Use Node's monotonic clock for the Steady cache lock's existing
10-second acquisition budget.
- Add two regression tests through the actual cache CLI for backward and
forward wall-clock corrections. The test preloads and child program are
static; paths and clock direction are passed as data.
- Keep the 50-ms polling interval, cancellation, lease ownership,
separate cleanup acquisition, and wall-clock file-aging timestamps
unchanged. No generated files, SDK runtime code, dependency pins, or
cache policy changes.

## Reproduction

On current main, hold the lifecycle lock and release it after 12 real
seconds. With no clock adjustment, the wrapper rejects the command with
its existing lock-timeout error. With a single 60-second backward
`Date.now()` correction after the acquisition deadline is established,
the same wrapper incorrectly launches the command after roughly 12.1
seconds and exits successfully.

This unaccelerated command-boundary reproduction fails before the fix on
Node 22.0.0, 24.19.0, and 26.7.0. After the fix, both the normal-clock
and corrected-clock cases reject late execution on all three runtimes,
preserve the existing owner's lock until it is released, and leave no
leases. The separate cleanup lock explains why the final process exit
occurs after the fixture releases the lock; that lifecycle behavior is
not changed here.

## Validation

- Both new regressions failed before the production change and passed
afterward.
- New clock and existing cancellation tests: 8 passed on Node 22.0.0,
22.22.3, 24.19.0, and 26.7.0. An independent reviewer also repeated the
clock tests five times successfully.
- Canonical cache expiry, active-lease, and cleanup checks passed on
Node 22.0.0, 24.19.0, and 26.7.0.
- Full canonical handwritten suite on the final files: 7,800 tests
passed across 205 files.
- Canonical lint/format, TypeScript checking, CJS/ESM build, and `git
diff --check` passed.
- Independent adversarial review found no security, compatibility,
lock-ownership, cancellation, or regression-test issues. Windows was
reviewed for path/spawn compatibility but not executed locally; the
generated suite will run in CI.

This is separate from openai#2657's file-processing timeout and retains
openai#2636's Steady cancellation behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant