web3-storage / web3.storage

DEPRECATED ⁂ The simple file storage service for IPFS & Filecoin
https://web3.storage
Other
501 stars 122 forks source link

Put fails with ERR_INVALID_THIS #2274

Closed legowerewolf closed 1 year ago

legowerewolf commented 1 year ago

push-storage.js

import { Web3Storage, getFilesFromPath } from "web3.storage";

const storage = new Web3Storage({ token: process.env.STORAGE_TOKEN });

const files = await getFilesFromPath("./ipfs/");

console.debug("files:", files);

const cid = await storage.put(files);

console.log("wrote CID:", cid);
> node push-storage.js
files: [
  {
    name: '/ipfs/index.html',
    stream: [Function: stream],
    mode: undefined,
    mtime: undefined,
    size: 778
  }
]
node:internal/errors:490
    ErrorCaptureStackTrace(err);
    ^

TypeError [ERR_INVALID_THIS]: Value of "this" must be of type URLSearchParams
    at new NodeError (node:internal/errors:399:5)
    at Proxy.has (node:internal/url:511:13)
    at Proxy.<anonymous> (file:///~~~/node_modules/@web-std/fetch/src/headers.js:140:44)
    at new Request (file:///~~~/node_modules/@web-std/fetch/src/request.js:105:38)
    at file:///~~~/node_modules/@web-std/fetch/src/index.js:40:19
    at new Promise (<anonymous>)
    at fetch (file:///~~~/node_modules/@web-std/fetch/src/index.js:38:9)
    at pRetry.retries (file:///~~~/node_modules/web3.storage/src/lib.js:221:30)
    at async RetryOperation._fn (~~~\node_modules\p-retry\index.js:50:12) {
  code: 'ERR_INVALID_THIS'
}

Node.js v20.2.0

Node 20.2.0 web3.storage 4.5.4 Windows 11 22H2 (22621.1778)

elias-prodigy commented 1 year ago

Same issue here. Ubuntu 20.04.6 LTS / Node v20.2.0 / web3.storage 4.5.4 Downgrading to Node.js 18.16.1 solved the problem

codingbiro commented 1 year ago

Any update on this?

tomjohnhall commented 1 year ago

Also hitting this error at the moment 😞

ctibo commented 1 year ago

Same issue here. Ubuntu 20.04.6 LTS / Node v20.2.0 / web3.storage 4.5.4 Downgrading to Node.js 18.16.1 solved the problem

Downgrading to Node 18.16.1 also worked for me :+1:

legowerewolf commented 1 year ago

Downgrading isn't a long-term solution, though. It's been a month and it doesn't seem like the issue's even been reviewed by maintainers, which is a little disheartening.