runAppleScript timeout errors report undefined milliseconds
Summary
runAppleScript(script, { timeout }) appears to enforce the timeout correctly, but timeout error messages can report:
Command timed out after undefined milliseconds: osascript
instead of the configured timeout value.
Examples in extension reports
This shows up across several raycast/extensions issues/PRs:
Likely cause
In src/run-applescript.ts, timeout is extracted from either optionsOrArgs or options and passed to getSpawnedPromise, so the process timeout is real:
const { humanReadableOutput, language, timeout, ...execOptions } = Array.isArray(optionsOrArgs)
? options || {}
: optionsOrArgs || {};
const spawnedPromise = getSpawnedPromise(spawned, { timeout: timeout ?? 10000 });
But defaultParsing receives options, which is undefined for the common object-style call:
runAppleScript(script, { timeout: 5000 })
Then src/exec-utils.ts formats the timeout message from options?.timeout, producing undefined milliseconds.
Expected
Timeout errors should include the effective timeout value, for example:
Command timed out after 5000 milliseconds: osascript
Actual
Timeout errors can show:
Command timed out after undefined milliseconds: osascript
Possible fix
Pass the effective timeout through to defaultParsing, for example by passing an options object that includes timeout: timeout ?? 10000.
runAppleScripttimeout errors reportundefined millisecondsSummary
runAppleScript(script, { timeout })appears to enforce the timeout correctly, but timeout error messages can report:instead of the configured timeout value.
Examples in extension reports
This shows up across several
raycast/extensionsissues/PRs:Likely cause
In
src/run-applescript.ts,timeoutis extracted from eitheroptionsOrArgsoroptionsand passed togetSpawnedPromise, so the process timeout is real:But
defaultParsingreceivesoptions, which is undefined for the common object-style call:Then
src/exec-utils.tsformats the timeout message fromoptions?.timeout, producingundefined milliseconds.Expected
Timeout errors should include the effective timeout value, for example:
Actual
Timeout errors can show:
Possible fix
Pass the effective timeout through to
defaultParsing, for example by passing an options object that includestimeout: timeout ?? 10000.