-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Description
AbortSignal.timeout() is a new Web API not available in older WebView2. See details below.
[Please copy the content from ISSUE_REPORT.md file]
Bug Report: AbortSignal.timeout is not a function
Summary
OpenCode fails to start on Windows with the error:
TypeError: AbortSignal.timeout is not a function
This occurs because AbortSignal.timeout() is a relatively new Web API that is not available in older WebView2 versions.
Environment
- OS: Windows
- OpenCode Version: 1.1.13 (installed from
D:\OpenCode\OpenCode.exe) - WebView2 Version: [Check with:
powershell "Get-ItemProperty 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}' | Select-Object pv"]
Steps to Reproduce
- Install OpenCode
- Launch
OpenCode.exe - Application fails to start with error in console
Error Details
TypeError: AbortSignal.timeout is not a function
at check (http://tauri.localhost/assets/index-DOiGjfJu.js:1705:38678)
at run (http://tauri.localhost/assets/index-DOiGjfJu.js:1705:38843)
at Object.fn (http://tauri.localhost/assets/index-DOiGjfJu.js:1705:38896)
at runComputation (http://tauri.localhost/assets/index-DOiGjfJu.js:2:8250)
at updateComputation (http://tauri.localhost/assets/index-DOiGjfJu.js:2:7981)
at runTop (http://tauri.localhost/assets/index-DOiGjfJu.js:2:9466)
at runUserEffects (http://tauri.localhost/assets/index-DOiGjfJu.js:2:10730)
at http://tauri.localhost/assets/index-DOiGjfJu.js:2:10322
at runUpdates (http://tauri.localhost/assets/index-DOiGjfJu.js:2:9655)
at completeUpdates (http://tauri.localhost/assets/index-DOiGjfJu.js:2:10315)
The error occurs in the updater plugin's check() function which uses AbortSignal.timeout().
Root Cause
The codebase uses AbortSignal.timeout() in multiple locations:
packages/app/src/context/server.tsxpackages/app/src/components/dialog-select-server.tsxpackages/opencode/src/provider/models.tspackages/opencode/src/provider/provider.tspackages/opencode/src/session/system.ts
This API is only available in:
- Chrome 103+
- Node.js 17.3.0+, 16.14.0+
- WebView2 (older versions don't support it)
Proposed Fix
Add a polyfill for AbortSignal.timeout at the entry point of each package.
Implementation
Create a polyfill file packages/util/src/abort-signal-polyfill.ts:
/**
* Polyfill for AbortSignal.timeout
*
* This API is not available in older WebView2 versions.
* This polyfill provides a compatible implementation.
*
* See: https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/timeout_static
*/
if (typeof (AbortSignal as any).timeout !== 'function') {
(AbortSignal as any).timeout = function(ms: number): AbortSignal {
const controller = new AbortController();
setTimeout(() => controller.abort(), ms);
return controller.signal;
};
}Then import it at the top of entry points:
packages/desktop/src/index.tsxpackages/app/src/index.tspackages/opencode/src/index.ts
Workaround
Users can work around this by:
- Upgrading WebView2 to the latest version
- Or installing Microsoft Edge (which includes the latest WebView2)
However, a polyfill is the better solution as it ensures compatibility.
Impact
This blocks users from using OpenCode on systems with older WebView2 versions, which is still common on Windows 10/11.