clasp icon indicating copy to clipboard operation
clasp copied to clipboard

Clasp push exits with code 0 when it fails

Open ddomonkos opened this issue 5 years ago • 7 comments

Was there an intention behind catching the exception and not letting the process exit with a non-zero code?

See https://github.com/google/clasp/blob/master/src/files.ts#L373

The reason why this matters is that we are using clasp in our CI/CD and the pipeline appears ok even if it, in reality, fails.

In our case the push failed because ts2gas transpiled into ES2019 rather than ES3.

Expected Behavior

When a clasp command fails, it exits with a non-zero code.

Actual Behavior

When clasp push fails, it exits with a zero code.

ddomonkos avatar Jul 01 '20 13:07 ddomonkos

@ddomonkos can you test with the #791 unofficial release?

npm uninstall -g @google/clasp && npm install -g forked-clasp
clasp --version
# should be 2.4.0 or more

PopGoesTheWza avatar Jul 15 '20 19:07 PopGoesTheWza

@ddomonkos What is the status for this issue?

PopGoesTheWza avatar Mar 19 '21 21:03 PopGoesTheWza

Sorry @PopGoesTheWza, we stopped using the library because we had to split it into separate build and upload steps.

Solely looking at the source code, I don't see any change in pushFiles function. Or maybe I'm just looking at the wrong place?

ddomonkos avatar Mar 20 '21 10:03 ddomonkos

@ddomonkos If you want to see the actual code, it is here: https://github.com/PopGoesTheWza/clasp/tree/forked

PopGoesTheWza avatar Mar 20 '21 18:03 PopGoesTheWza

Should be fixed in https://github.com/google/clasp/releases/tag/v2.3.1

PopGoesTheWza avatar May 12 '21 22:05 PopGoesTheWza

Is there a command line flag or clasp.json setting that needs to be enabled?

With clasp 2.3.2, I still get a zero exit code if I push code that explicitly has an error:

$ ./node_modules/.bin/clasp push && echo success!
- Pushing files...Push failed. Errors:
GaxiosError: Syntax error: SyntaxError: Unexpected token ';' line: 31 file: main.gs
    at Gaxios._request (/home/cldellow/src/ds-connector/node_modules/gaxios/build/src/gaxios.js:85:23)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async OAuth2Client.requestAsync (/home/cldellow/src/ds-connector/node_modules/google-auth-library/build/src/auth/oauth2client.js:350:18) {
...lots of gaxios output omitted...
  code: 400,
  errors: [
    {
      message: "Syntax error: SyntaxError: Unexpected token ';' line: 31 file: main.gs",
      domain: 'global',
      reason: 'badRequest'
    }
  ]
}
└─ src/appsscript.json
└─ src/fields.js
└─ src/main.js
Pushed 3 files.
success!

Clasp 2.4.1 fails some node assertion and dumps core:

$ ./node_modules/.bin/clasp push && echo success!
node[1213831]: ../src/api/callback.cc:129:void node::InternalCallbackScope::Close(): Assertion `(env_->execution_async_id()) == (0)' failed.
 1: 0xb17ec0 node::Abort() [node]
 2: 0xb17f3e  [node]
 3: 0xa59021 node::InternalCallbackScope::Close() [node]
 4: 0xa590e1 node::InternalCallbackScope::~InternalCallbackScope() [node]
 5: 0xb1baf7 node::fs::FileHandle::CloseReq::Resolve() [node]
 6: 0xb1bc79  [node]
 7: 0x158ab2d  [node]
 8: 0x158f186  [node]
 9: 0x15a1f15  [node]
10: 0x158fab8 uv_run [node]
11: 0xa59f25 node::SpinEventLoop(node::Environment*) [node]
12: 0xb59bd7 node::NodeMainInstance::Run(node::EnvSerializeInfo const*) [node]
13: 0xadfaa2 node::Start(int, char**) [node]
14: 0x7f2b0a88f0b3 __libc_start_main [/lib/x86_64-linux-gnu/libc.so.6]
15: 0xa57d6c  [node]
Aborted (core dumped)

cldellow avatar Jan 13 '22 18:01 cldellow