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

(node:133220) UnhandledPromiseRejectionWarning: Error: [object Object] at Gaxios.<anonymous> …at Generator.next (<anonymous>) #1651

Closed
aminasya opened this issue Mar 24, 2019 · 9 comments
Assignees
Labels
status: investigating The issue is under investigation, which is determined to be non-trivial. type: question Request for information or clarification. Not an issue.

Comments

@aminasya
Copy link

Environment details

  • OS: Windows 10
  • Node.js version: v10.14.1
  • npm version: 6.4.1
  • googleapis version: 38

Steps to reproduce

  1. node .\download.js 1Z9c119EzgR4Dd5Woi-C34Xl6Qu_87FugdlwwYRJhzlE

This code produces following error:

writing to C:\Users\ASHOT_~1\AppData\Local\Temp\a9b522b9-0582-4dc3-b73c-0b9593892ff3
(node:143084) UnhandledPromiseRejectionWarning: Error: [object Object]
    at Gaxios.<anonymous> (C:\Users\Ashot_Minasyan\Downloads\google-api-nodejs-client-master\google-api-nodejs-client-master\node_modules\gaxios\build\src\gaxios.js:72:27)
    at Generator.next (<anonymous>)
    at fulfilled (C:\Users\Ashot_Minasyan\Downloads\google-api-nodejs-client-master\google-api-nodejs-client-master\node_modules\gaxios\build\src\gaxios.js:16:58)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:143084) 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: 1)
(node:143084) [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.

Running quickstart.js works ok so authentication is not a problem I think.
Here is stackoverflow question https://stackoverflow.com/questions/55326387/node133220-unhandledpromiserejectionwarning-error-object-object-at-gaxios

@JustinBeckwith JustinBeckwith added needs more info This issue needs more information from the customer to proceed. type: question Request for information or clarification. Not an issue. labels Mar 24, 2019
@JustinBeckwith
Copy link
Contributor

Greetings! Can you share the code you're using?

@aminasya
Copy link
Author

aminasya commented Mar 24, 2019

@aminasya
Copy link
Author

This actually worked with another file (normal pdf). The file which cause this error is template. Looks like it needs additional treating.

@JustinBeckwith
Copy link
Contributor

Thanks! Can you share the type of file you're downloading?

@bcoe
Copy link
Contributor

bcoe commented Apr 4, 2019

@aminasya 👋 are you still bumping into issues? what was the extension of the file you were attempting to download.

@aminasyaEpam
Copy link

The file that I tried do download was google template document. In order to download it the type should be specified. I managed to do it using api.epxort method specifying 'application/pdf' as type.
So the error message came when I tried to call get method with a template document.

@bcoe bcoe added status: investigating The issue is under investigation, which is determined to be non-trivial. and removed needs more info This issue needs more information from the customer to proceed. labels Apr 8, 2019
@bcoe bcoe self-assigned this Apr 8, 2019
@bcoe
Copy link
Contributor

bcoe commented Apr 22, 2019

@aminasya (CC: @aminasyaEpam are you the same person?), if I understand you are able to download templates as long as you specify the mimeType and use the export method rather than get method?

@JustinBeckwith
Copy link
Contributor

Greetings! We haven't seen any action on this issue for a while, so we're going to go ahead and close it out. If this is still a problem... please do let us know!

@NetajiBandi
Copy link

NetajiBandi commented Jun 15, 2019

I was just able to reproduce this bug and fix it as well.

I was mistaken by thinking that the issue is having alt: 'media' under params of drive.files.get
But for me issue turned out to be an insufficient permissions.

I was using the token.json file which got saved before all the needed scopes were defined.
I initially had only below two scopes,

['https://www.googleapis.com/auth/drive.metadata',
'https://www.googleapis.com/auth/drive.metadata.readonly']

But after adding all the required scopes (required for download) as below,

const SCOPES = [
  'https://www.googleapis.com/auth/drive',
  'https://www.googleapis.com/auth/drive.appdata',
  'https://www.googleapis.com/auth/drive.file',
  'https://www.googleapis.com/auth/drive.metadata',
  'https://www.googleapis.com/auth/drive.metadata.readonly',
  'https://www.googleapis.com/auth/drive.photos.readonly',
  'https://www.googleapis.com/auth/drive.readonly',
];

And deleted the old token.json file. This created a new token.json file, and then the download started working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: investigating The issue is under investigation, which is determined to be non-trivial. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

5 participants