-
Notifications
You must be signed in to change notification settings - Fork 353
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
built-in fetch
in node 20 issues error
#1130
Comments
Thanks for the report! We're looking into it. I'll follow up here once I have an update for you. |
We've updated the server configuration. Can you try again now and let me know if you're still seeing this issue? |
Thanks. I think this issue is solved now. |
Sorry for reopening. const { result } = await dbx.filesDownload({ path: item.path_lower }) TypeError: res.buffer is not a function
at /.../node_modules/dropbox/cjs/src/response.js:67:11
at new Promise (<anonymous>)
at parseDownloadResponse (/.../node_modules/dropbox/cjs/src/response.js:61:10)
at /.../node_modules/dropbox/cjs/src/dropbox.js:146:52
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) The built-in I think the built-in |
Thanks! I'll raise this with the team. |
@eouia This code snippet is a TypeScript function that utilizes the Dropbox SDK and this is how I solved the fetch error. import { Dropbox } from "dropbox";
import { env } from "@/validation/env";
import { Account } from "@/types/db";
export default function dropbox(account: Account) {
if (!account) {
throw new Error("Dropbox account not found");
}
const customFetch = async (input: RequestInfo, init?: RequestInit): Promise<Response> => {
const response = await globalThis.fetch(input, init);
return Object.defineProperty(response, "buffer", {
value: response.arrayBuffer,
});
};
return new Dropbox({
fetch: customFetch,
clientId: env.DROPBOX_ID,
clientSecret: env.DROPBOX_SECRET,
accessToken: account.access_token!,
refreshToken: account.refresh_token!,
});
} remember to treat the buffer as an const nodeBuffer = Buffer.from(arrBuffer); |
I suspect the old node-fetch dependency is also triggering a punycode deprecation warning via and old whatwg-url dependency |
@Downchuck If you're seeing an issue, please an open issue and share the details, e.g., the steps to reproduce it and the output you get, so we can look into it. Thanks in advance! |
Describe the bug
In node version 20 (v20.8.0), built-in fetch() could issue an error. Version 18 (v18.5.0) has no issue.
To Reproduce
/examples/javascript/PKCE-backend/code_flow_example.js
To use built-in
fetch
, I comment outnode-fetch
.Expected Behavior
In V18,
fetch
andnode-fetch
worked without issue.Actual Behavior
In V20, built-in
fetch
claims the issue after app consent.Versions
The text was updated successfully, but these errors were encountered: