Skip to content

res.buffer is not a function in bun #1135

@aviadbd

Description

@aviadbd

Describe the bug
I am migrating my web app to bun, and it seems the dropbox SDK usage fails to download files.

To Reproduce

  1. Download bun. I'm using 1.0.30.
  2. Install Dropbox SDK JS - bun install --save-dev dropbox
  3. Using this code:
// dropbox.ts

const dropbox = new Dropbox({accessToken: process.env.DROPBOX_ACCESS_TOKEN, fetch: fetch});

const result = await dropbox.filesListFolder({path: "/products", recursive: true})

dropbox.filesDownload({path: "/path/to/file.jpg"}).then(
    {result} => {
        console.debug(result.name)
    }
).catch(err => {
    console.error(err)
})
  1. Run it using bun dropbox.ts

Expected Behavior
I expect it to run, and print the name of my file. The file exists in the path, and is accessible to the app (the node JS app finds it and has access to it; moreover, if I use a non-existent file, I get a 409 error, and I don't in this case).

Actual Behavior
I get an error, like this:

62 |     if ((0, _utils.isWindowOrWorker)()) {
63 |       res.blob().then(function (data) {
64 |         return resolve(data);
65 |       });
66 |     } else {
67 |       res.buffer().then(function (data) {
           ^
TypeError: res.buffer is not a function. (In 'res.buffer()', 'res.buffer' is undefined)
      at /project/node_modules/dropbox/cjs/src/response.js:67:7
      at new Promise (:1:21)
      at parseDownloadResponse (/project/node_modules/dropbox/cjs/src/response.js:61:10)
      at /project/node_modules/dropbox/cjs/src/dropbox.js:146:20

Screenshots
N/A

Versions

  • What version of the SDK are you using? 10.34.0
  • What version of the language are you using? Whatever Bun's using
  • Are you using Javascript or Typescript? TypeScript
  • What platform are you using? (if applicable) Bun 1.0.30

Additional context
None.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions