Skip to content

Commit

Permalink
fix: node fetch (#144)
Browse files Browse the repository at this point in the history
* fdp-play fx, works well with node 20

* Update package-lock.json

* node-fetch 3.3.2 -> 2

* fix: node-fetch bump

* ci: adjust node versions

* ci: remove 20 temp

* build: add node fetch type

* ci: readd node 20

* ci: remove node 20

---------

Co-authored-by: Laszlo Fazekas <thebojda@gmail.com>
  • Loading branch information
nugaon and TheBojda authored Jun 14, 2024
1 parent f903da7 commit ef6d623
Show file tree
Hide file tree
Showing 8 changed files with 5,394 additions and 5,712 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

strategy:
matrix:
node-version: [16.x]
node-version: [18.x]

steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
steps:
- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
registry-url: 'https://registry.npmjs.org'

- name: Checkout
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-npmjs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm publish --access public
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ docs
.vscode

generator/build
yarn.lock
11,084 changes: 5,379 additions & 5,705 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"dockerode": "^4.0.2",
"ethers": "^5.7.2",
"furious-commander": "^1.7.1",
"node-fetch": "3.0.0-beta.9",
"node-fetch": "^2",
"ora": "^5.3.0"
},
"devDependencies": {
Expand All @@ -66,6 +66,7 @@
"@types/dockerode": "^3.3.24",
"@types/jest": "^27.4.1",
"@types/node": "^18.11.8",
"@types/node-fetch": "^2.6.11",
"@types/terser-webpack-plugin": "^5.2.0",
"@types/webpack": "^5.28.0",
"@types/webpack-bundle-analyzer": "^4.4.1",
Expand Down
8 changes: 7 additions & 1 deletion src/shim/crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,11 @@ const getRandomValuesNode = <T extends ArrayBufferView | null>(array: T): T => {
}

if (isNode && globalThis) {
globalThis.crypto = { ...globalThis.crypto, getRandomValues: getRandomValuesNode }
if (!globalThis.crypto) {
globalThis.crypto = {} as Crypto;
}

if (!globalThis.crypto.getRandomValues) {
globalThis.crypto.getRandomValues = getRandomValuesNode;
}
}
4 changes: 2 additions & 2 deletions src/utils/wait.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import fetch, { FetchError } from 'node-fetch'
import { default as __fetch, FetchError } from 'node-fetch'
import { sleep } from './index'
import { TimeoutError } from './error'
import { BeeDebug } from '@ethersphere/bee-js'
Expand Down Expand Up @@ -40,7 +40,7 @@ function isAllowedError(e: FetchError): boolean {
export async function waitForBlockchain(waitingIterations = 30): Promise<void> {
for (let i = 0; i < waitingIterations; i++) {
try {
const request = await fetch('http://127.0.0.1:9545', {
const request = await __fetch('http://127.0.0.1:9545', {
method: 'POST',
body: BLOCKCHAIN_BODY_REQUEST,
headers: { 'Content-Type': 'application/json' },
Expand Down

0 comments on commit ef6d623

Please sign in to comment.