question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`gaxios` treats `arraybuffer` differently from `axios`

See original GitHub issue

Thanks for stopping by to let us know something could be better!

PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.

Please run down the following list and make sure you’ve tried the usual “quick fixes”:

If you are still having issues, please be sure to include as much information as possible:

Environment details

  • OS: MacOS
  • Node.js version: 10.5.0
  • npm version: 6.7.0
  • googleapis version: 37.0.0

Steps to reproduce

With the move to gaxios from axios, there’s a few things that have changed with regard to how node-fetch handles arraybuffer differently from axios. (Mainly, it does nothing to it at all 🙃 .) I will say that this is not necessarily a bug, but for anyone else who depends on this to run drive.files.export calls may be surprised the exported files stop working.

In axios, it will convert an ArrayBuffer to a Buffer as part of the request, but node-fetch leaves that up to the user.

So in pre-37.0.0 land, this would work fine (and return a Buffer at res.data):

const res = await drive.files.export(
  {
    fileId: spreadsheetId,
    mimeType:
      'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
  },
  { responseType: 'arraybuffer' }
);

But now in 37.0.0, you may have to pass that to Buffer.from before you can potentially use it.

Like I said above - this may not actually be a “bug” in the traditional sense, but seeing as I learned the tip of how to use arraybuffer with drive.files.export to pull down Excel files from the issues of this library, I figured I’d flag it just in case it’s worth noting somewhere? (Just not sure… where?)

Thanks for the library!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
rdmurphycommented, Mar 23, 2019

@JustinBeckwith Sounds good! I agree. Probably best to let fetch continue to work like fetch, it’ll not be an issue as this change becomes the understood “default.” (I adjusted in my code and it has been fine ever since.) Hopefully folks will find this if they happen to hit it. 👍

1reaction
JustinBeckwithcommented, Mar 23, 2019

Given the current behavior makes a lot more sense, I’m content to close this one out. Please do let me know if there’s anything else we could do here!

Read more comments on GitHub >

github_iconTop Results From Across the Web

how does axios handle blob vs arraybuffer as responseType?
So when downloading data as an 'arraybuffer' , you get entirely different data? It now makes sense to me that the unzipping library...
Read more >
axios vs gaxios vs got vs https vs node-fetch | npm trends
Comparing trends for axios 1.2.1 which has 37188700 weekly downloads and 97796 ... ArrayBuffer, // FormData or Stream // You may modify the...
Read more >
Buffer with zipped file HELP. Buffer => XML => JSON - Reddit
When I console.log the axios data response the data looks like wing dings. Not a typical array buffer.
Read more >
Notices for RQA customer-managed - IBM
purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES. WITH REGARD TO...
Read more >
Open Source Used In slido-test 22.06 - Cisco
1.145 axios-retry 3.2.5 ... 1.662 base64-arraybuffer 1.0.1 ... may provide additional or different license terms and conditions.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found