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

Commit

Permalink
fix: use fetch in electron renderer and electron-fetch in main (#3251)
Browse files Browse the repository at this point in the history
Lets us run test on Linux which roughly halves the amount of time Electron CI tasks take.
  • Loading branch information
achingbrain committed Oct 10, 2020
1 parent 8e44e52 commit 639d71f
Show file tree
Hide file tree
Showing 61 changed files with 79 additions and 78 deletions.
8 changes: 0 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,11 @@ jobs:

- stage: test
name: electron-main
os: osx
script:
- npm run test:electron-main -- $RUN_SINCE -- -- --bail --timeout 60000

- stage: test
name: electron-renderer
os: osx
script:
- npm run test:electron-renderer -- $RUN_SINCE -- -- --bail --timeout 60000

Expand All @@ -115,13 +113,11 @@ jobs:

- stage: test
name: interop - electron-main
os: osx
script:
- npm run test:interop -- $RUN_SINCE -- -- -- -t electron-main -f ./test/node.js --bail --timeout 60000

- stage: test
name: interop - electron-renderer
os: osx
script:
- npm run test:interop -- $RUN_SINCE -- -- -- -t electron-renderer -f ./test/browser.js -bail --timeout 60000

Expand Down Expand Up @@ -152,13 +148,11 @@ jobs:

- stage: test
name: js-ipfs interface tests - electron main
os: osx
script:
- npm run test:interface:core -- $RUN_SINCE -- -- --bail -t electron-main --timeout 60000

- stage: test
name: js-ipfs interface tests - electron renderer
os: osx
script:
- npm run test:interface:core -- $RUN_SINCE -- -- --bail -t electron-renderer --timeout 60000

Expand Down Expand Up @@ -214,13 +208,11 @@ jobs:

- stage: test
name: http-api-client interface tests vs js-ipfs - electron main
os: osx
script:
- npm run test:interface:http-js -- $RUN_SINCE -- -- --bail -t electron-main --timeout 60000

- stage: test
name: http-api-client interface tests vs js-ipfs - electron renderer
os: osx
script:
- npm run test:interface:http-js -- $RUN_SINCE -- -- --bail -t electron-renderer --timeout 60000

Expand Down
4 changes: 2 additions & 2 deletions examples/browser-ipns-publish/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"human-crypto-keys": "^0.1.4",
"ipfs": "^0.50.1",
"ipfs-http-client": "^47.0.0",
"ipfs-utils": "^3.0.0",
"ipfs-utils": "^4.0.0",
"ipns": "^0.8.0",
"it-last": "^1.0.4",
"p-retry": "^4.2.0",
Expand All @@ -27,7 +27,7 @@
"devDependencies": {
"delay": "^4.4.0",
"execa": "^4.0.3",
"ipfsd-ctl": "^7.0.0",
"ipfsd-ctl": "^7.0.2",
"go-ipfs": "^0.7.0",
"parcel-bundler": "^1.12.4",
"path": "^0.12.7",
Expand Down
2 changes: 1 addition & 1 deletion examples/explore-ethereum-blockchain/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"devDependencies": {
"ipfs": "^0.50.1",
"ipfs-http-client": "^47.0.0",
"ipfsd-ctl": "^7.0.0",
"ipfsd-ctl": "^7.0.2",
"test-ipfs-example": "^2.0.3"
}
}
2 changes: 1 addition & 1 deletion examples/http-client-browser-pubsub/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"execa": "^4.0.3",
"go-ipfs": "^0.7.0",
"ipfs": "^0.50.1",
"ipfsd-ctl": "^7.0.0",
"ipfsd-ctl": "^7.0.2",
"parcel-bundler": "^1.12.4",
"test-ipfs-example": "^2.0.3"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/http-client-bundle-webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"copy-webpack-plugin": "^5.0.4",
"execa": "^4.0.3",
"ipfs": "^0.50.1",
"ipfsd-ctl": "^7.0.0",
"ipfsd-ctl": "^7.0.2",
"react-hot-loader": "^4.12.21",
"test-ipfs-example": "^2.0.3",
"webpack": "^4.43.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/http-client-name-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"devDependencies": {
"execa": "^4.0.3",
"go-ipfs": "^0.7.0",
"ipfsd-ctl": "^7.0.0",
"ipfsd-ctl": "^7.0.2",
"parcel-bundler": "^1.12.4",
"test-ipfs-example": "^2.0.3"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/interface-ipfs-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
],
"license": "MIT",
"dependencies": {
"abort-controller": "^3.0.0",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"chai-subset": "^1.6.0",
Expand All @@ -41,7 +40,7 @@
"err-code": "^2.0.3",
"ipfs-unixfs": "^2.0.3",
"ipfs-unixfs-importer": "^3.0.4",
"ipfs-utils": "^3.0.0",
"ipfs-utils": "^4.0.0",
"ipld-block": "^0.10.1",
"ipld-dag-cbor": "^0.17.0",
"ipld-dag-pb": "^0.20.0",
Expand All @@ -59,6 +58,7 @@
"multibase": "^3.0.0",
"multihashing-async": "^2.0.1",
"nanoid": "^3.1.12",
"native-abort-controller": "~0.0.3",
"p-map": "^4.0.0",
"peer-id": "^0.14.1",
"readable-stream": "^3.4.0",
Expand All @@ -67,7 +67,7 @@
},
"devDependencies": {
"aegir": "^27.0.0",
"ipfsd-ctl": "^7.0.0"
"ipfsd-ctl": "^7.0.2"
},
"contributors": [
"Alan Shaw <alan.shaw@protocol.ai>",
Expand Down
2 changes: 1 addition & 1 deletion packages/interface-ipfs-core/src/bitswap/wantlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { getDescribe, getIt, expect } = require('../utils/mocha')
const { waitForWantlistKey, waitForWantlistKeyToBeRemoved } = require('./utils')
const { isWebWorker } = require('ipfs-utils/src/env')
const testTimeout = require('../utils/test-timeout')
const AbortController = require('abort-controller')
const AbortController = require('native-abort-controller')
const CID = require('cids')
const delay = require('delay')

Expand Down
2 changes: 1 addition & 1 deletion packages/interface-ipfs-core/src/pubsub/subscribe.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const all = require('it-all')
const { waitForPeers, getTopic } = require('./utils')
const { getDescribe, getIt, expect } = require('../utils/mocha')
const delay = require('delay')
const AbortController = require('abort-controller')
const AbortController = require('native-abort-controller')
const { isWebWorker, isNode } = require('ipfs-utils/src/env')

/** @typedef { import("ipfsd-ctl/src/factory") } Factory */
Expand Down
2 changes: 1 addition & 1 deletion packages/ipfs-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"ipfs-http-gateway": "0.0.1",
"ipfs-http-server": "0.0.1",
"ipfs-repo": "^6.0.3",
"ipfs-utils": "^3.0.0",
"ipfs-utils": "^4.0.0",
"ipld-dag-cbor": "^0.17.0",
"ipld-dag-pb": "^0.20.0",
"it-all": "^1.0.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/ipfs-core-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"browser-readablestream-to-it": "0.0.2",
"cids": "^1.0.0",
"err-code": "^2.0.3",
"ipfs-utils": "^3.0.0",
"ipfs-utils": "^4.0.0",
"it-all": "^1.0.4",
"it-map": "^1.0.4",
"it-peekable": "0.0.1",
Expand Down
6 changes: 3 additions & 3 deletions packages/ipfs-core-utils/test/files/normalise-input.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ const blobToIt = require('blob-to-it')
const uint8ArrayFromString = require('uint8arrays/from-string')
const all = require('it-all')
const { Blob, ReadableStream } = require('ipfs-utils/src/globalthis')
const { isBrowser, isWebWorker } = require('ipfs-utils/src/env')
const { isBrowser, isWebWorker, isElectronRenderer } = require('ipfs-utils/src/env')

let normalise = require('../../src/files/normalise-input')

if (isBrowser || isWebWorker) {
if (isBrowser || isWebWorker || isElectronRenderer) {
normalise = require('../../src/files/normalise-input/index.browser')
}

Expand All @@ -34,7 +34,7 @@ async function verifyNormalisation (input) {

let content = input[0].content

if (isBrowser || isWebWorker) {
if (isBrowser || isWebWorker || isElectronRenderer) {
expect(content).to.be.an.instanceOf(Blob)
content = blobToIt(content)
}
Expand Down
6 changes: 3 additions & 3 deletions packages/ipfs-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
"dep-check": "aegir dep-check"
},
"dependencies": {
"abort-controller": "^3.0.0",
"any-signal": "^2.0.0",
"array-shuffle": "^1.0.1",
"bignumber.js": "^9.0.0",
Expand All @@ -69,7 +68,7 @@
"ipfs-unixfs": "^2.0.3",
"ipfs-unixfs-exporter": "^3.0.4",
"ipfs-unixfs-importer": "^3.0.4",
"ipfs-utils": "^3.0.0",
"ipfs-utils": "^4.0.0",
"ipld": "^0.27.1",
"ipld-bitcoin": "^0.4.0",
"ipld-block": "^0.10.1",
Expand Down Expand Up @@ -108,6 +107,7 @@
"multibase": "^3.0.0",
"multicodec": "^2.0.1",
"multihashing-async": "^2.0.1",
"native-abort-controller": "~0.0.3",
"p-defer": "^3.0.0",
"p-queue": "^6.6.1",
"parse-duration": "^0.4.4",
Expand All @@ -119,7 +119,7 @@
"devDependencies": {
"aegir": "^27.0.0",
"delay": "^4.4.0",
"ipfsd-ctl": "^7.0.0",
"ipfsd-ctl": "^7.0.2",
"interface-ipfs-core": "^0.140.0",
"iso-random-stream": "^1.1.1",
"iso-url": "^0.4.7",
Expand Down
2 changes: 1 addition & 1 deletion packages/ipfs-core/src/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const toUri = require('multiaddr-to-uri')
const debug = require('debug')
const CID = require('cids')
const shuffle = require('array-shuffle')
const AbortController = require('abort-controller').default
const AbortController = require('native-abort-controller')
const preload = require('./runtime/preload-nodejs')

const log = Object.assign(
Expand Down
7 changes: 3 additions & 4 deletions packages/ipfs-http-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,13 @@
"dep-check": "aegir dep-check"
},
"dependencies": {
"abort-controller": "^3.0.0",
"any-signal": "^2.0.0",
"bignumber.js": "^9.0.0",
"cids": "^1.0.0",
"debug": "^4.1.1",
"form-data": "^3.0.0",
"ipfs-core-utils": "^0.4.0",
"ipfs-utils": "^3.0.0",
"ipfs-utils": "^4.0.0",
"ipld-block": "^0.10.1",
"ipld-dag-cbor": "^0.17.0",
"ipld-dag-pb": "^0.20.0",
Expand All @@ -65,7 +64,7 @@
"multicodec": "^2.0.1",
"multihashes": "^3.0.1",
"nanoid": "^3.1.12",
"node-fetch": "^2.6.0",
"native-abort-controller": "~0.0.3",
"parse-duration": "^0.4.4",
"stream-to-it": "^0.2.2",
"uint8arrays": "^1.1.0"
Expand All @@ -75,7 +74,7 @@
"cross-env": "^7.0.0",
"go-ipfs": "^0.7.0",
"interface-ipfs-core": "^0.140.0",
"ipfsd-ctl": "^7.0.0",
"ipfsd-ctl": "^7.0.2",
"it-all": "^1.0.4",
"it-concat": "^1.0.1",
"it-pipe": "^1.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/ipfs-http-client/src/add-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const configure = require('./lib/configure')
const multipartRequest = require('./lib/multipart-request')
const toUrlSearchParams = require('./lib/to-url-search-params')
const anySignal = require('any-signal')
const AbortController = require('abort-controller').default
const AbortController = require('native-abort-controller')

module.exports = configure((api) => {
/**
Expand Down
2 changes: 1 addition & 1 deletion packages/ipfs-http-client/src/block/put.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const multipartRequest = require('../lib/multipart-request')
const configure = require('../lib/configure')
const toUrlSearchParams = require('../lib/to-url-search-params')
const anySignal = require('any-signal')
const AbortController = require('abort-controller').default
const AbortController = require('native-abort-controller')

module.exports = configure(api => {
/**
Expand Down
2 changes: 1 addition & 1 deletion packages/ipfs-http-client/src/config/replace.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const multipartRequest = require('../lib/multipart-request')
const configure = require('../lib/configure')
const toUrlSearchParams = require('../lib/to-url-search-params')
const anySignal = require('any-signal')
const AbortController = require('abort-controller').default
const AbortController = require('native-abort-controller')

module.exports = configure(api => {
return async (config, options = {}) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/ipfs-http-client/src/dag/put.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const configure = require('../lib/configure')
const multipartRequest = require('../lib/multipart-request')
const toUrlSearchParams = require('../lib/to-url-search-params')
const anySignal = require('any-signal')
const AbortController = require('abort-controller').default
const AbortController = require('native-abort-controller')
const multicodec = require('multicodec')

module.exports = configure((api, opts) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/ipfs-http-client/src/files/write.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const configure = require('../lib/configure')
const multipartRequest = require('../lib/multipart-request')
const toUrlSearchParams = require('../lib/to-url-search-params')
const anySignal = require('any-signal')
const AbortController = require('abort-controller').default
const AbortController = require('native-abort-controller')

module.exports = configure(api => {
return async (path, input, options = {}) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const normaliseInput = require('ipfs-core-utils/src/files/normalise-input')
const normaliseInput = require('ipfs-core-utils/src/files/normalise-input/index.browser')
const modeToString = require('./mode-to-string')
const mtimeToObject = require('./mtime-to-object')
const { File, FormData } = require('ipfs-utils/src/globalthis')
Expand Down
5 changes: 5 additions & 0 deletions packages/ipfs-http-client/src/lib/multipart-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const modeToString = require('../lib/mode-to-string')
const mtimeToObject = require('../lib/mtime-to-object')
const merge = require('merge-options').bind({ ignoreUndefined: true })
const toStream = require('it-to-stream')
const { isElectronRenderer } = require('ipfs-utils/src/env')

async function multipartRequest (source = '', abortController, headers = {}, boundary = `-----------------------------${nanoid()}`) {
async function * streamFiles (source) {
Expand Down Expand Up @@ -73,3 +74,7 @@ async function multipartRequest (source = '', abortController, headers = {}, bou
}

module.exports = multipartRequest

if (isElectronRenderer) {
module.exports = require('./multipart-request.browser')
}
2 changes: 1 addition & 1 deletion packages/ipfs-http-client/src/object/patch/append-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const multipartRequest = require('../../lib/multipart-request')
const configure = require('../../lib/configure')
const toUrlSearchParams = require('../../lib/to-url-search-params')
const anySignal = require('any-signal')
const AbortController = require('abort-controller').default
const AbortController = require('native-abort-controller')

module.exports = configure(api => {
return async (cid, data, options = {}) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/ipfs-http-client/src/object/patch/set-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const multipartRequest = require('../../lib/multipart-request')
const configure = require('../../lib/configure')
const toUrlSearchParams = require('../../lib/to-url-search-params')
const anySignal = require('any-signal')
const AbortController = require('abort-controller').default
const AbortController = require('native-abort-controller')

module.exports = configure(api => {
return async (cid, data, options = {}) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/ipfs-http-client/src/object/put.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const multipartRequest = require('../lib/multipart-request')
const configure = require('../lib/configure')
const toUrlSearchParams = require('../lib/to-url-search-params')
const anySignal = require('any-signal')
const AbortController = require('abort-controller').default
const AbortController = require('native-abort-controller')
const unit8ArrayToString = require('uint8arrays/to-string')
const uint8ArrayFromString = require('uint8arrays/from-string')

Expand Down
2 changes: 1 addition & 1 deletion packages/ipfs-http-client/src/pubsub/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const configure = require('../lib/configure')
const toUrlSearchParams = require('../lib/to-url-search-params')
const multipartRequest = require('../lib/multipart-request')
const anySignal = require('any-signal')
const AbortController = require('abort-controller').default
const AbortController = require('native-abort-controller')

module.exports = configure(api => {
return async (topic, data, options = {}) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const AbortController = require('abort-controller').default
const AbortController = require('native-abort-controller')

class SubscriptionTracker {
constructor () {
Expand Down

0 comments on commit 639d71f

Please sign in to comment.