Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

TypeError: RequestInit: duplex option is required when sending a body. #4276

Closed
Raman-Raje opened this issue Jan 6, 2023 · 11 comments
Closed
Labels
need/triage Needs initial labeling and prioritization

Comments

@Raman-Raje
Copy link

Raman-Raje commented Jan 6, 2023

Hi,
I was working with ipfs-http-client version ^59.0.0. Everything was working fine, and I did some updates through brew, and Node got updated to V19. Previously I was on V18.13.0

Now the code is giving above mentioned error while performing ipfs.add operation.
For other ipfs operations, everything is working fine.
I did downgrade to node V18.13.0, but the issue is still there. I am not sure what wrong i am doing.

I am using Mac OS.
Here is the code to reproduce the issue...

const ipfs = create({
    host: 'ipfs.infura.io',
    port: 5001,
    protocol: 'https',
    headers: {
        authorization: auth,
    },
});

const filepath = "./github.png";

fs.readFile(filepath, async (err , data) => {
    if (err){
        console.error(err);
    }
    const filename = filepath.split("/").pop();
    const result = await ipfs.add({path:filename,content:Buffer.from(data)});
    console.log(result);
}); 

Here is the error log :-

TypeError: RequestInit: duplex option is required when sending a body.
    at Object.fetch (node:internal/deps/undici/undici:14062:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Client.fetch (/Users/raman/Desktop/ipfs/ipfsNode/node_modules/ipfs-utils/src/http.js:132:22)
    at async addAll (file:///Users/raman/Desktop/ipfs/ipfsNode/node_modules/ipfs-http-client/src/add-all.js:36:17)
    at async last (file:///Users/raman/Desktop/ipfs/ipfsNode/node_modules/it-last/dist/src/index.js:7:22)
    at async Object.add (file:///Users/raman/Desktop/ipfs/ipfsNode/node_modules/ipfs-http-client/src/add.js:22:14)
@Raman-Raje Raman-Raje added the need/triage Needs initial labeling and prioritization label Jan 6, 2023
@welcome
Copy link

welcome bot commented Jan 6, 2023

Thank you for submitting your first issue to this repository! A maintainer will be here shortly to triage and review.
In the meantime, please double-check that you have provided all the necessary information to make this process easy! Any information that can help save additional round trips is useful! We currently aim to give initial feedback within two business days. If this does not happen, feel free to leave a comment.
Please keep an eye on how this issue will be labeled, as labels give an overview of priorities, assignments and additional actions requested by the maintainers:

  • "Priority" labels will show how urgent this is for the team.
  • "Status" labels will show if this is ready to be worked on, blocked, or in progress.
  • "Need" labels will indicate if additional input or analysis is required.

Finally, remember to use https://discuss.ipfs.io if you just need general support.

@Vectorrent
Copy link

Vectorrent commented Jan 8, 2023

I am seeing the same problem. I tried a bunch of old versions, and they all seem to do the same thing. Here's the code:

import { create } from 'ipfs-http-client'

const ipfs = create({ url: '/ip4/127.0.0.1/tcp/5001' })
const { cid } = await ipfs.add('Hello world!')
console.log(cid)

And here's the output:

> node root.js

node:internal/deps/undici/undici:14062
    Error.captureStackTrace(err, this);
          ^

TypeError: RequestInit: duplex option is required when sending a body.
    at Object.fetch (node:internal/deps/undici/undici:14062:11)
    at async Client.fetch (/home/crow/Repos/src/node_modules/ipfs-utils/src/http.js:132:22)
    at async addAll (file:///home/crow/Repos/src/node_modules/ipfs-http-client/src/add-all.js:36:17)
    at async last (file:///home/crow/Repos/src/node_modules/it-last/dist/src/index.js:7:22)
    at async Object.add (file:///home/crow/Repos/src/node_modules/ipfs-http-client/src/add.js:22:14)
    at async file:///home/crow/Repos/src/root.js:10:17

Node.js v19.3.0

@miladezzat
Copy link

any update for this issue

@Raman-Raje
Copy link
Author

I have found the solution. In my case, my node version got updated. Reverted it back to V16. Its working fine for me

@lucas-sdl
Copy link

What version node are you on? I'm hitting this error on 16.17.1

@Raman-Raje
Copy link
Author

I am on V16.15.1. Try This one. Best Luck

@miladezzat
Copy link

I am switch to v18.12.1 and it works fine

@dvncan
Copy link

dvncan commented Jan 12, 2023

^ditto.. I didnt specify my node version past 18.x.x when deploying to heroku where they had recently changed default from 18.12 -> 18.13 which seems to break ipfs-https-client

@Raman-Raje
Copy link
Author

I believe its resolved now. Closing the issue

@SilvioGuedes
Copy link

I believe its resolved now. Closing the issue

The problem is still happening:

TypeError: RequestInit: duplex option is required when sending a body.

NodeJS v18.15.0
IPFS (Kubo) v0.19.1
Windows 10

@ejim11
Copy link

ejim11 commented Jun 5, 2023

TypeError: RequestInit: duplex option is required when sending a body.

This issue is still happening. Please how can I resolve it?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
need/triage Needs initial labeling and prioritization
Projects
None yet
Development

No branches or pull requests

7 participants