Skip to content

fix(speech): enforce the timeout through audio download - #321

Open
jihtsan wants to merge 2 commits into
modelstudioai:mainfrom
jihtsan:codex/fix/309-speech-timeout
Open

jihtsan wants to merge 2 commits into
modelstudioai:mainfrom
jihtsan:codex/fix/309-speech-timeout

Conversation

@jihtsan

@jihtsan jihtsan commented Nov 13, 2026 •

Copy link
Copy Markdown

Closes #309.

Nonstreaming speech synthesis first requests an audio URL, then downloads it. The download did not use the command timeout, so it could stall after receiving audio bytes. One deadline now covers both requests, including headers and the response body. A timed-out download reports exit code 5 and a structured error. Audio is staged beside its destination and replaces the destination only after a successful download, preserving ordinary POSIX permission bits when replacing an existing regular file. A failed concurrent operation cancels and awaits its local peers while preserving the original error.

Verification on macOS, Node.js 24.22.1, pnpm 10.33.2, Vite+ with 4 test workers:

  • The six regression cases failed on the unchanged base with the same fixtures (8.92 s test time) and passed with the fix. Cases cover stalled headers, a stalled body, a deadline shared by synthesis and download, an existing WAV, a failed concurrent peer, and CLI --timeout exit behavior.
  • The current patch passes 147 tests (33.57 s wall time), including speech output, progress output, core HTTP, HTTP timeouts and the Bun transport suite. The release-pinned Bun 1.3.14 also ran the CLI harness against a loopback server: stalled headers and partial bodies both returned exit code 5 and kept the prior file intact.
  • With umask 022, both POSIX mode regressions failed against the previous PR commit (1.59 s) and passed with this patch (1.49 s): a successful WAV replacement preserves 0600 and 0664 and writes the new bytes. The mode cases are skipped on Windows.
  • pnpm exec vp check passed with two warnings in unchanged files. No live DashScope, distributed bl binary, or server-side cancellation was verified.

Prepared with Codex; all provider responses used in the regressions are local fixtures.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-13T05:43:34.629605Z 872e54d PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 872e54dcbe

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +104 to +106
await pipeline(Readable.fromWeb(body), meter, createWriteStream(partialPath), { signal });
signal.throwIfAborted();
await rename(partialPath, destPath);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve existing output permissions during atomic replacement

When nonstreaming synthesis overwrites an existing 0600 output under the usual 022 umask, createWriteStream(partialPath) creates a 0644 file and rename installs those wider permissions over the destination. The previous createWriteStream(destPath) preserved the existing file's mode; a focused before/after check confirmed this regression. In a directory accessible to other users, regenerating a private recording therefore makes it readable to them without warning. Preserve the existing destination's mode on the staged file before renaming it.

Useful? React with 👍 / 👎.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] speech synthesize --timeout 180 does not terminate stalled audio streaming

1 participant