我在排查录音转写的超时问题时,发现 `speech recognize --timeout` 没有传到临时 OSS 文件上传这一步。上传仍固定等待120秒,而报错提示会建议增大 `--timeout`,因此调整这个参数对上传阶段没有效果。 已搜索现有 Issue,并核对官方 v2.1.0 和当前 main 的实现,相关代码一致。 ### 环境 - BL、core、commands、runtime:2.1.0 - Node.js:v24.21.0 - Windows 11 x64,北京地域 ### 问题位置 1. [`packages/core/src/client/client.ts` 的 `Client.uploadFile()`](http://github.com/modelstudioai/cli/blob/fc080016469f33ce6726ae997d0ff6428c19aa49/packages/core/src/client/client.ts#L152-L157) 调用 `resolveFileUrl()` 时没有传入有效配置中的 `settings.timeout`: ```ts return resolveFileUrl(source, this.requireApi().token, model, { ...opts, identity: this.deps.identity, }); ``` 2. [`packages/core/src/files/upload.ts` 的 `uploadToOSS()`](http://github.com/modelstudioai/cli/blob/fc080016469f33ce6726ae997d0ff6428c19aa49/packages/core/src/files/upload.ts#L88) 则直接使用固定计时器: ```ts const uploadSignal = combineWithTimeout(120_000, signal); ``` 因此,即使 CLI 指定 `--timeout 3600`,OSS 上传也不会使用这个值;上传耗时超过120秒时仍会被中止。 ### 建议修改 沿现有调用链传递 timeout 即可: - 在 `Client.uploadFile()` 的上传选项中加入 `timeout: this.deps.settings.timeout`。 - 在 `resolveFileUrl()` 的选项类型及 `UploadOptions` 中增加等待秒数,并经 `uploadFile()` 传入 `uploadToOSS()`。 - 将 OSS 上传计时器改为 `combineWithTimeout(timeout * 1000, signal)`。直接调用 SDK 且未传 timeout 时,可以保留原有120秒默认值。 获取上传凭证的15秒计时器与文件上传是两个阶段;本次建议针对实际文件上传。 ### 本机核对结果 用合成凭据及模拟响应记录原生计时器:设置 `timeout: 1` 时,原版的文件上传计时器仍为120000毫秒。按上述方式透传后变为1000毫秒。另用延迟上传合约核对,一秒设置下300毫秒上传可完成,0.1秒设置下会按时中止。 希望文件上传也能遵循已解析的 timeout,让参数和超时提示的行为一致。
Activity