Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Error when IPFS-desktop is running bind: address already in use #25

Closed
SgtPooki opened this issue Apr 21, 2022 · 8 comments · Fixed by #28
Closed

Bug: Error when IPFS-desktop is running bind: address already in use #25

SgtPooki opened this issue Apr 21, 2022 · 8 comments · Fixed by #28

Comments

@SgtPooki
Copy link
Member

npx -p @ipfs-shipyard/pinning-service-compliance@0.0.2 -- pinning-service-compliance -s $PINATA_API_ENDPOINT $PINATA_API_TOKEN
Request with no authentication token
        ✓ Response object matches api spec schema
        ✘ Returns a 403
Request with invalid token
        ✓ Response object matches api spec schema
        ✘ Returns a 403
2022-04-21T23:24:12.016Z [error] : Problem running compliance check: 'addPin': Error: Initializing daemon...
go-ipfs version: 0.12.1
Repo version: 12
System version: arm64/darwin
Golang version: go1.16.12
Swarm listening on /ip4/127.0.0.1/tcp/4001
Swarm listening on /ip4/192.168.1.227/tcp/4001
Swarm listening on /ip6/::1/tcp/4001
Swarm listening on /p2p-circuit
Swarm announcing /ip4/127.0.0.1/tcp/4001
Swarm announcing /ip4/192.168.1.227/tcp/4001
Swarm announcing /ip6/::1/tcp/4001
 

 Error: serveHTTPApi: manet.Listen(/ip4/127.0.0.1/tcp/5001) failed: listen tcp4 127.0.0.1:5001: bind: address already in use 

 Command failed with exit code 1: node_modules/.bin/ipfs daemon
Error: serveHTTPApi: manet.Listen(/ip4/127.0.0.1/tcp/5001) failed: listen tcp4 127.0.0.1:5001: bind: address already in use
Initializing daemon...
go-ipfs version: 0.12.1
Repo version: 12
System version: arm64/darwin
Golang version: go1.16.12
Swarm listening on /ip4/127.0.0.1/tcp/4001
Swarm listening on /ip4/192.168.1.227/tcp/4001
Swarm listening on /ip6/::1/tcp/4001
Swarm listening on /p2p-circuit
Swarm announcing /ip4/127.0.0.1/tcp/4001
Swarm announcing /ip4/192.168.1.227/tcp/4001
Swarm announcing /ip6/::1/tcp/4001
 


2022-04-21T23:24:14.707Z [error] : Problem running compliance check: 'deleteNewPin': Error: Initializing daemon...
go-ipfs version: 0.12.1
Repo version: 12
System version: arm64/darwin
Golang version: go1.16.12
Swarm listening on /ip4/127.0.0.1/tcp/4001
Swarm listening on /ip4/192.168.1.227/tcp/4001
Swarm listening on /ip6/::1/tcp/4001
Swarm listening on /p2p-circuit
Swarm announcing /ip4/127.0.0.1/tcp/4001
Swarm announcing /ip4/192.168.1.227/tcp/4001
Swarm announcing /ip6/::1/tcp/4001
 

 Error: serveHTTPApi: manet.Listen(/ip4/127.0.0.1/tcp/5001) failed: listen tcp4 127.0.0.1:5001: bind: address already in use 

 Command failed with exit code 1: node_modules/.bin/ipfs daemon
Error: serveHTTPApi: manet.Listen(/ip4/127.0.0.1/tcp/5001) failed: listen tcp4 127.0.0.1:5001: bind: address already in use
Initializing daemon...
go-ipfs version: 0.12.1
Repo version: 12
System version: arm64/darwin
Golang version: go1.16.12
Swarm listening on /ip4/127.0.0.1/tcp/4001
Swarm listening on /ip4/192.168.1.227/tcp/4001
Swarm listening on /ip6/::1/tcp/4001
Swarm listening on /p2p-circuit
Swarm announcing /ip4/127.0.0.1/tcp/4001
Swarm announcing /ip4/192.168.1.227/tcp/4001
Swarm announcing /ip6/::1/tcp/4001
 


List pin objects (GET /pins) in all states
        ✓ Response object matches api spec schema
        ✓ Response is successful
        ✓ Response statusCode is 200
2022-04-21T23:24:17.853Z [error] : Problem running compliance check: 'replacePin': Error: Initializing daemon...
go-ipfs version: 0.12.1
Repo version: 12
System version: arm64/darwin
Golang version: go1.16.12
Swarm listening on /ip4/127.0.0.1/tcp/4001
Swarm listening on /ip4/192.168.1.227/tcp/4001
Swarm listening on /ip6/::1/tcp/4001
Swarm listening on /p2p-circuit
Swarm announcing /ip4/127.0.0.1/tcp/4001
Swarm announcing /ip4/192.168.1.227/tcp/4001
Swarm announcing /ip6/::1/tcp/4001
 

 Error: serveHTTPApi: manet.Listen(/ip4/127.0.0.1/tcp/5001) failed: listen tcp4 127.0.0.1:5001: bind: address already in use 

 Command failed with exit code 1: node_modules/.bin/ipfs daemon
Error: serveHTTPApi: manet.Listen(/ip4/127.0.0.1/tcp/5001) failed: listen tcp4 127.0.0.1:5001: bind: address already in use
Initializing daemon...
go-ipfs version: 0.12.1
Repo version: 12
System version: arm64/darwin
Golang version: go1.16.12
Swarm listening on /ip4/127.0.0.1/tcp/4001
Swarm listening on /ip4/192.168.1.227/tcp/4001
Swarm listening on /ip6/::1/tcp/4001
Swarm listening on /p2p-circuit
Swarm announcing /ip4/127.0.0.1/tcp/4001
Swarm announcing /ip4/192.168.1.227/tcp/4001
Swarm announcing /ip6/::1/tcp/4001
 


2022-04-21T23:24:20.722Z [error] : Problem running compliance check: 'matchPin': Error: Initializing daemon...
go-ipfs version: 0.12.1
Repo version: 12
System version: arm64/darwin
Golang version: go1.16.12
Swarm listening on /ip4/127.0.0.1/tcp/4001
Swarm listening on /ip4/192.168.1.227/tcp/4001
Swarm listening on /ip6/::1/tcp/4001
Swarm listening on /p2p-circuit
Swarm announcing /ip4/127.0.0.1/tcp/4001
Swarm announcing /ip4/192.168.1.227/tcp/4001
Swarm announcing /ip6/::1/tcp/4001
 

 Error: serveHTTPApi: manet.Listen(/ip4/127.0.0.1/tcp/5001) failed: listen tcp4 127.0.0.1:5001: bind: address already in use 

 Command failed with exit code 1: node_modules/.bin/ipfs daemon
Error: serveHTTPApi: manet.Listen(/ip4/127.0.0.1/tcp/5001) failed: listen tcp4 127.0.0.1:5001: bind: address already in use
Initializing daemon...
go-ipfs version: 0.12.1
Repo version: 12
System version: arm64/darwin
Golang version: go1.16.12
Swarm listening on /ip4/127.0.0.1/tcp/4001
Swarm listening on /ip4/192.168.1.227/tcp/4001
Swarm listening on /ip6/::1/tcp/4001
Swarm listening on /p2p-circuit
Swarm announcing /ip4/127.0.0.1/tcp/4001
Swarm announcing /ip4/192.168.1.227/tcp/4001
Swarm announcing /ip6/::1/tcp/4001
 


Get all pins
        ✓ Response is ok
        ✓ Result is not null
2022-04-21T23:24:23.688Z [error] : Problem running compliance check: 'testPagination': Error: Initializing daemon...
go-ipfs version: 0.12.1
Repo version: 12
System version: arm64/darwin
Golang version: go1.16.12
Swarm listening on /ip4/127.0.0.1/tcp/4001
Swarm listening on /ip4/192.168.1.227/tcp/4001
Swarm listening on /ip6/::1/tcp/4001
Swarm listening on /p2p-circuit
Swarm announcing /ip4/127.0.0.1/tcp/4001
Swarm announcing /ip4/192.168.1.227/tcp/4001
Swarm announcing /ip6/::1/tcp/4001
 

 Error: serveHTTPApi: manet.Listen(/ip4/127.0.0.1/tcp/5001) failed: listen tcp4 127.0.0.1:5001: bind: address already in use 

 Command failed with exit code 1: node_modules/.bin/ipfs daemon
Error: serveHTTPApi: manet.Listen(/ip4/127.0.0.1/tcp/5001) failed: listen tcp4 127.0.0.1:5001: bind: address already in use
Initializing daemon...
go-ipfs version: 0.12.1
Repo version: 12
System version: arm64/darwin
Golang version: go1.16.12
Swarm listening on /ip4/127.0.0.1/tcp/4001
Swarm listening on /ip4/192.168.1.227/tcp/4001
Swarm listening on /ip6/::1/tcp/4001
Swarm listening on /p2p-circuit
Swarm announcing /ip4/127.0.0.1/tcp/4001
Swarm announcing /ip4/192.168.1.227/tcp/4001
Swarm announcing /ip6/::1/tcp/4001
@SgtPooki SgtPooki added bug good first issue Good for newcomers labels Apr 21, 2022
@SgtPooki
Copy link
Member Author

The culprit here is https://github.com/ipfs-shipyard/pinning-service-compliance/blob/addMoreChecks-update-1/src/utils/getInlineCid.ts#L8-L20

@lidel if this error throws, can I use the running ipfs daemon? How would I do that?

@lidel
Copy link
Member

lidel commented Apr 25, 2022

@SgtPooki hm.. rule of thumb would be to avoid reusing an already running daemon , if possible (compliance tests should spawn a clean, dedicated, ephemeral instance that we fully control, so we don't inject garbage into user's node repo)

iiuc src/utils/getInlineCid.ts#L8-L20 does not require any state persistence, so try running it via createFactory with:

        test: true,
        disposable: true,

test profile should solve your problem – will pick random port etc

SgtPooki added a commit that referenced this issue Apr 25, 2022
@SgtPooki SgtPooki linked a pull request Apr 25, 2022 that will close this issue
@achingbrain
Copy link
Member

If all you're doing is creating an inline CID from a piece of data, why not just use the identity hash from the multiformats module to do that instead of spinning up a daemon, creating a repo, opening ports, etc?

@lidel
Copy link
Member

lidel commented Apr 26, 2022

My understanding is that we still need daemon, as we want to add tests which require real bitswap and DHT announcement.

As for inline CID creation, agree, left comment in #28 (review)

@SgtPooki
Copy link
Member Author

This is fixed in the latest PR, thanks though!

@SgtPooki
Copy link
Member Author

I will handle the online CID using multiformats as suggested, that will speed things up a bit

@SgtPooki
Copy link
Member Author

My understanding is that we still need daemon, as we want to add tests which require real bitswap and DHT announcement.

As for inline CID creation, agree, left comment in #28 (review)

We don't have any other checks implemented that use daemon yet, so the ephemeral &test daemon should be a non-blocker as soon as I improve the inline CID implementation.

@SgtPooki SgtPooki unpinned this issue Apr 27, 2022
SgtPooki added a commit that referenced this issue May 5, 2022
* fix: Use existing client if one is running

fixes #25

* chore: update contributors

* chore: release version v0.0.3

* fix: Use a clean controlled ipfsd-ctl daemon

* fix: Create inline CID with multiformats

Do not use a daemon for creating an inline CID

Using the following snippet,
```typescript
(async () => {
  try {
    const inlineCid = await getInlineCid()
    console.log(inlineCid)
  } catch (err) {
    console.error(err)
  }
})().catch((err) => {
  console.error(err)
})
```

we see that multiformats is easily 9x faster:

```bash
> hyperfine 'ts-node src/utils/getInlineCid-daemon.ts' 'ts-
node src/utils/getInlineCid-multiformats.ts'
Benchmark 1: ts-node src/utils/getInlineCid-daemon.ts
  Time (mean ± σ):      3.056 s ±  0.187 s    [User: 1.154 s, System: 0.260 s]
  Range (min … max):    2.922 s …  3.405 s    10 runs

Benchmark 2: src/utils/getInlineCid-multiformats.ts
  Time (mean ± σ):     314.9 ms ±   2.8 ms    [User: 319.3 ms, System: 41.3 ms]
  Range (min … max):   310.9 ms … 320.3 ms    10 runs

Summary
  'src/utils/getInlineCid-multiformats.ts' ran
    9.71 ± 0.60 times faster than 'ts-node src/utils/getInlineCid-daemon.ts'
```

* fix: correct getInlineCID error output

* chore: tsconfig correctio
ns
github-actions bot pushed a commit that referenced this issue Jun 14, 2022
## 1.0.0 (2022-06-14)

### Features

* add npm bin to devcontainer PATH ([365c142](365c142))
* auto-update github actions with dependabot ([#43](#43)) ([87f7926](87f7926))
* compliance check infrastructure ([7aa5663](7aa5663))
* Export esm module ([#41](#41)) ([acaeac6](acaeac6))
* implement all compliance checks ([#17](#17)) ([1223831](1223831)), closes [#5](#5) [#4](#4) [#6](#6) [#7](#7) [#8](#8) [#28](#28) [#25](#25)
* lplaceholder checks run via listr ([bbb1f81](bbb1f81))
* Publish static reports via github pages ([#68](#68)) ([5a6a7f5](5a6a7f5)), closes [#78](#78) [#76](#76) [#77](#77) [#77](#77)

### Bug Fixes

* CI release succeeds ([#90](#90)) ([810d4a2](810d4a2))
* Compliance check sum is consistent for all services ([#54](#54)) ([ace2b57](ace2b57)), closes [#55](#55)
* devcontainer sees pinning-service-client ([c7a6dbb](c7a6dbb))

### Trivial Changes

* **deps-dev:** bump @types/node from 17.0.25 to 17.0.34 ([#49](#49)) ([a2a5d13](a2a5d13))
* **deps-dev:** bump @types/node from 17.0.35 to 17.0.41 ([#79](#79)) ([db8a6f7](db8a6f7))
* **deps-dev:** bump aegir from 37.0.15 to 37.2.0 ([#86](#86)) ([df4035f](df4035f))
* **deps-dev:** bump ipfs-core-types from 0.10.3 to 0.11.0 ([#64](#64)) ([e623ad3](e623ad3))
* **deps-dev:** bump ts-node from 10.7.0 to 10.8.1 ([#75](#75)) ([ff48f3b](ff48f3b))
* **deps:** bump actions/checkout from 2 to 3 ([#46](#46)) ([8fbbcd8](8fbbcd8))
* **deps:** bump actions/setup-node from 2 to 3 ([#48](#48)) ([ee57c59](ee57c59))
* **deps:** bump github/codeql-action from 1 to 2 ([#47](#47)) ([1dd488d](1dd488d))
* **deps:** bump go-ipfs from 0.12.2 to 0.13.0 ([#80](#80)) ([baaaa8c](baaaa8c))
* **deps:** bump ipfsd-ctl from 10.0.6 to 11.0.1 ([#58](#58)) ([45771db](45771db))
* **deps:** bump lewagon/wait-on-check-action from 0.2 to 1.1.1 ([#44](#44)) ([9c8f5c0](9c8f5c0))
* **deps:** bump node-fetch from 3.2.4 to 3.2.6 ([#81](#81)) ([5bcb760](5bcb760))
* **deps:** bump pascalgn/automerge-action from 0.13.1 to 0.15.3 ([#45](#45)) ([65c19dc](65c19dc))
* getting started instructions ([b7ff148](b7ff148))
* ignore .envrc ([54e5aae](54e5aae))
* static report landing page provides context ([#87](#87)) ([12fc841](12fc841))
* use gitignore.io ([e81ebd9](e81ebd9))
@github-actions
Copy link

🎉 This issue has been resolved in version 1.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment