Erratic Google Cloud Function when running a shell script


March 2019


6 time


I am trying to run a shell script on a Google Cloud Function.

I am using Node as the framework, and have tried different ways to run the script: execSync, execFileSync, spawnSync, etc:

try {
    const output = require('child_process').execSync(__dirname + '/', [], 
        stdio: 'inherit',
        shell: '/bin/bash'
catch (error) {

The behavior I get is very erratic. Overall I think it worked once, but the rest of the time I either get a connection error and nothing happens, or the function terminates "successfully", but nothing from the shell script gets outputted, so I don't know whether it even ran or not.

I couldn't detect a pattern in when it fails and when it runs.

0 answers