Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unhandled promise rejection #344

Closed
JaimeChavarriaga opened this issue Oct 6, 2018 · 5 comments
Closed

unhandled promise rejection #344

JaimeChavarriaga opened this issue Oct 6, 2018 · 5 comments
Milestone

Comments

@JaimeChavarriaga
Copy link

When I try to run some commands with a wrong user, the clasp shows error messages caused by problems with the permissions but remains frozen.

Expected Behavior

Trying to run a command, clasp must show an error message and end.

$ clasp logs --json
Error: User has not been authorized
(end)

NOTE: This happens also with other commands such as clasp deploy.

Actual Behavior

The clasp application shows an error...

 clasp logs --json
- Using local credentials: ./clasprc.json 🔐 Grabbing logs...(node:16843) UnhandledPromiseRejectionWarning: Error: The caller does not have permission
    at createError (/usr/lib/node_modules/@google/clasp/node_modules/axios/lib/core/createError.js:16:15)
    at settle (/usr/lib/node_modules/@google/clasp/node_modules/axios/lib/core/settle.js:18:12)
    at Unzip.handleStreamEnd (/usr/lib/node_modules/@google/clasp/node_modules/axios/lib/adapters/http.js:201:11)
    at emitNone (events.js:111:20)
    at Unzip.emit (events.js:208:7)
    at endReadableNT (_stream_readable.js:1064:12)
    at _combinedTickCallback (internal/process/next_tick.js:139:11)
    at process._tickCallback (internal/process/next_tick.js:181:9)
(node:16843) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:16843) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
/ Using local credentials: ./clasprc.json 
🔐 Grabbing logs...

but remains frozen. I must stop the clasp using [Ctrl]+[C]

Steps to Reproduce the Problem

  1. Create an App Script project where users can see the project if they have the link
  2. Login using clasp: clasp login
  3. Clone/Pull the content of the above mentioned project: clasp clone ....
  4. Run commands such as clasp deploy or clasp login --json

Specifications

  • Node version (node -v): v10.11.0
  • Version (clasp -v): 1.6.3
  • OS (Mac/Linux/Windows): Linux -- Ubuntu 18.04.1 LTS
@grant
Copy link
Contributor

grant commented Oct 6, 2018

Thanks for reporting.
There was a recent change in using JS promises (async/await). I'll have to make the error handling a bit better.

Ideally, this is mitigated when multi-user support #42.

@emckean
Copy link

emckean commented Oct 16, 2018

I ran into a similar issue while trying clasp login
screen shot 2018-10-15 at 10 26 19 am

@grant grant added this to the Clasp V2 milestone Oct 29, 2018
@takanakahiko
Copy link
Contributor

I think that it is better to use try/catch for error handling.

like this.

try {
  deployments = await script.projects.deployments.update({
    scriptId,
    deploymentId,
    requestBody: {
      deploymentConfig: {
        versionNumber,
        manifestFileName: PROJECT_MANIFEST_BASENAME,
        description,
      },
    },
  })
}catch(err){
  return logError(null, err.message);
}

@grant
Copy link
Contributor

grant commented Nov 10, 2018

Yes, I'll need to add a try/catch block at the top-most level for each command.
This became a problem after moving to async/await.

This was referenced Nov 17, 2018
@grant
Copy link
Contributor

grant commented Nov 17, 2018

This error shouldn't happen anymore in the next clasp release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants