Skip to content

Diagnostic reference

Attempted to execute myFunction, but could not save

Fix Google Apps Script 'Attempted to execute myFunction, but could not save' caused by syntax errors, invalid appsscript.json, or expired sessions.

Updated December 6, 2026

Apps Script error

Attempted to execute myFunction, but could not save.

What it means

Clicking Run in the Apps Script editor automatically tries to save every open file before executing. If any .gs file has a syntax error (such as an unclosed string, missing brace, or unsupported syntax), if appsscript.json contains invalid JSON, or if your Google session or network connection dropped, the save aborts and Apps Script refuses to run the function.

Related error messages

  • Attempted to execute <functionName>, but could not save.
  • Syntax error: SyntaxError: Unexpected end of input
  • Syntax error: SyntaxError: Invalid or unexpected token

Before and after

The code before and after the fix.

Problem 3 changed lines
// A syntax error in any file blocks saving, so clicking Run reports:
// "Attempted to execute myFunction, but could not save."
function myFunction() {
  const message = 'Ready
  Logger.log(message);
}
Fixed 4 changed lines
// 1. Fix any syntax error across every .gs and appsscript.json file.
// 2. Press Ctrl+S (or Cmd+S) and wait until the Save icon disables.
// 3. Click Run once the project saves cleanly.
function myFunction() {
  const message = 'Ready';
  Logger.log(message);
}

How to fix it

  • Click the Save icon (or press Ctrl+S / Cmd+S) by itself so the editor prints the exact file and line number blocking the save.
  • Check every .gs file in the project, not only the active tab, for unclosed quotes, missing parentheses or braces, or duplicate top-level const/let declarations.
  • If you enabled appsscript.json in Project Settings, verify it is valid JSON with no trailing commas or comments.
  • If there are no syntax errors, copy your unsaved edits, reload the script.google.com tab to refresh your Google session, paste back, and save again.

Things to check

  • Signing into multiple Google accounts in the same browser profile can cause save requests to fail with permission or session errors; test in a single-account profile or Incognito window.
  • Projects exceeding the Apps Script file or project size limit also fail to save until unused generated data is moved to Drive or Sheets.

In the Apps Script editor

Catch errors like this before clicking Run.

myFunction (published as Error Checker for Google Apps Script on the Chrome Web Store) checks your code while you edit at script.google.com. Diagnostics, autocomplete, and rule-based quick fixes are free without an account, run in your browser, and request no Google Drive, Gmail, or Apps Script project OAuth scopes. Writing Apps Script with an AI coding agent? Connect the Apps Script MCP server to run the same static checks before pasting code.