labnol / apps-script-starter

Setup a local development environment inside Visual Studio Code and build Google Workspace add-ons with Google Apps Script
https://www.youtube.com/watch?v=KxdCIbeO4Uk
MIT License
1.1k stars 176 forks source link

Using object getter function will fail debugger #16

Closed eabadjiev closed 4 years ago

eabadjiev commented 5 years ago

When using a getter function the GAS Editor debugging will fail with We're sorry, a server error occurred. The script will run as expected.

Steps to reproduce:

  1. Clone the app-script-starter repo
  2. Add a class with getter function

    
    class Fail {
    constructor() {
    this.log = ['a', 'b', 'c'];
    }
    
    get latest() {
    return this.log[this.log.length - 1];
    }
    }

global.failDebugger = () => { const f = new Fail(); Logger.log(Fail: ${f.latest}); };


3. Debug `failDebugger` from GAS Editor

Expected result: 
- be able to debug

Actual result:
- debugger fails w/ `We're sorry, a server error occurred`

Few notes:
- actually it is not needed the functionality `Fail` to be used for the debugger to fail
- the starter we where using was inspired (creative copy/paste) from Atlassian [Gmail Addon](https://medium.com/@jsarafajr/google-apps-script-without-pain-or-success-story-of-atlassian-cloud-for-gmail-6cd99ba40de0)
labnol commented 4 years ago

The Apps Script Starter Kit now uses the v8 Runtime that should resolve the issue.