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

ReferenceError: AbortController is not defined #4019

Closed
ethdev279 opened this issue Jan 19, 2022 · 9 comments
Closed

ReferenceError: AbortController is not defined #4019

ethdev279 opened this issue Jan 19, 2022 · 9 comments
Labels
need/triage Needs initial labeling and prioritization

Comments

@ethdev279
Copy link

  • Version: 55.0.0
  • Platform: Nodejs 14.5.0 on macOs
  • Subsystem: Don't know

Severity:

Description:

Getting error ReferenceError: AbortController is not defined

Tried to use ipfs-http-client v55.0.0 in nodejs like below. It seems working fine in client side(reactjs app) but it is throwing error in nodejs backend

import { create } from "ipfs-http-client";
const ipfsClient = create({ host: 'ipfs.infura.io', port: 5001, protocol: 'https' });

const { path } = await ipfsClient.add('Hello World');
console.log(path)

Steps to reproduce the error:

@ethdev279 ethdev279 added the need/triage Needs initial labeling and prioritization label Jan 19, 2022
@clarkjoao
Copy link

clarkjoao commented Jan 19, 2022

Has one solution in progressing #4015 but still waiting other fix be finished.
while the solution does not come out, I'm using upload via https. doc

@achingbrain
Copy link
Member

Please upgrade to node 16 - node 14 is not supported any more. AbortController is global in node 15+ so this should resolve your issue.

@ethdev279
Copy link
Author

@achingbrain I wonder why it is working on react app of same node(14.5.0) environment?

@achingbrain
Copy link
Member

React runs in the browser and AbortController has been global there for a long time.

@gary02
Copy link

gary02 commented Mar 28, 2022

Please upgrade to node 16 - node 14 is not supported any more. AbortController is global in node 15+ so this should resolve your issue.

I use ipfs-http-client in aws lambda ( .zip file archives way) which do not support node 16 yet.

@OrderAndCh4oS
Copy link

OrderAndCh4oS commented Apr 30, 2022

Please upgrade to node 16 - node 14 is not supported any more. AbortController is global in node 15+ so this should resolve your issue.

I use ipfs-http-client in aws lambda ( .zip file archives way) which do not support node 16 yet.

I'm also using AWS Lambda with a Node 14 Runtime. I got around the issue by installing node-abort-controller and setting it on the global.

import {AbortController} from "node-abort-controller";

global.AbortController = AbortController;

Seems to work fine, have been able to add files to IPFS with no trouble.

https://www.npmjs.com/package/node-abort-controller

@achingbrain
Copy link
Member

@OrderAndCh4oS that's a decent workaround until AWS allows everyone to use Active LTS versions of node.

kuzdogan added a commit to ethereum/sourcify that referenced this issue May 17, 2022
Implement the postponed complete upgrade to node v16 to circumvent the
ipfs-js issue: ipfs/js-ipfs#4019
kuzdogan added a commit to ethereum/sourcify that referenced this issue May 17, 2022
Implement the postponed complete upgrade to node v16 to circumvent the
ipfs-js issue: ipfs/js-ipfs#4019
@achingbrain
Copy link
Member

Closing because a solution has been found - either upgrade to node 16 or use a polyfill.

@gary02
Copy link

gary02 commented Jul 18, 2022

@OrderAndCh4oS that's a decent workaround until AWS allows everyone to use Active LTS versions of node.

aws lambda support node 16 now

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

5 participants