-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Description
Extension
https://www.raycast.com/raycast/apple-notes
Raycast Version
1.104.6
OS Version
26.2
Description
getNoteBody() and setNoteBody() in api/applescript.ts call runAppleScript() without specifying a timeout. The default in @raycast/utils is 10 seconds (10,000ms). When Notes.app is not already running, the AppleScript tell application "Notes" triggers an app launch, which can easily exceed 10 seconds.
The resulting error message is:
Error: Command timed out after undefined milliseconds: osascript
(The "undefined" is a cosmetic bug in @raycast/utils error reporting — options?.timeout is undefined because no options were passed, even though the actual timeout used was 10s.)
Suggested Fix
Pass an explicit timeout to runAppleScript in getNoteBody and setNoteBody:
export async function getNoteBody(id: string) {
return runAppleScript(
`
tell application "Notes"
set theNote to note id "${escapeDoubleQuotes(id)}"
return body of theNote
end tell
`,
{ timeout: 30000 },
);
}
export async function setNoteBody(id: string, body: string) {
return runAppleScript(
`
tell application "Notes"
set theNote to note id "${escapeDoubleQuotes(id)}"
set body of theNote to "${escapeDoubleQuotes(body)}"
end tell
`,
{ timeout: 30000 },
);
}30 seconds provides enough headroom for Notes.app to launch, while still failing reasonably quickly if something is actually wrong.
Note: The "timed out after undefined milliseconds" phrasing in the error message is a separate minor bug in @raycast/utils — it reads options?.timeout for the error string, but when no options are passed, the timeout is applied internally as a default without being set on the options object.
Steps To Reproduce
- Quit Notes.app
- Ask the AI to read a note's content
get-note-contentcallsgetNoteBody()→runAppleScript()with default 10s timeout- Notes.app begins launching but doesn't finish within 10 seconds
- Timeout error
Current Behaviour
When Notes.app is not already running, get-note-content and update-note fail with:
Error: Command timed out after undefined milliseconds: osascript
The error occurs because the default 10-second timeout in @raycast/utils is too short for Notes.app to launch. The "undefined milliseconds" phrasing is a secondary cosmetic bug caused by the timeout not being explicitly set in the options object passed to runAppleScript.
Expected Behaviour
get-note-content and update-note should work reliably whether or not Notes.app is already running. With an explicit 30-second timeout passed to runAppleScript, Notes.app has sufficient time to launch and respond to the AppleScript command.