Problem
Nested trigger on GAS v8 engine doesn't work if I use clasp typescript project. "Nested trigger" means a scheduled function which is programmatically created by another scheduled function.
- clasp: v2.3.0
How to reproduce
- Create clasp project
clasp create --type standalone - Create a TypeScript file called
main.tswith the following contents:
// Set trigger on a specific time.
function setTrigger(time:Date, func:string): void {
console.log('This is scheduling: ' + func + ' on ' + time);
ScriptApp.newTrigger(func)
.timeBased()
.at(time)
.create();
}
// Set trigger on 5 minutes after.
function schedule() {
const toBeScheduled = new Date();
toBeScheduled.setMinutes(toBeScheduled.getMinutes() + 5);
setTrigger(toBeScheduled, "doSomething");
}
// function which will fire.
function doSomething() {
console.log("DO SOMETHING");
}
- Create a json file called
tsconfig.jsonwith the following contents:
{
"compilerOptions": {
"lib": ["esnext"],
"target": "ES2019",
"experimentalDecorators": true
}
}
- push code
clasp push - Set trigger for
schedule()function every 5 minutes so that thedoSomething()fire every 5 min.
but actually the doSomething() doesn't fire. The trigger is set but it will be disabled with UNKNOWN cause.
Note
- If I manually execute
schedule(), thendoSomething()fires as expected. - If I create a GAS project with exactly same contents without clasp, then
doSomething()fires as expected. - If I push code without v8 engine as following, then everything works fine.
- Remove
"runtimeVersion": "V8"fromappsscript.json - Remove
tsconfig.jsonfile from project.
- Remove
Is there something I'm missing?
Update(2020/04/18)
I have created issue on the issue tracker.
https://issuetracker.google.com/154366756