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

fix: create HTTP servers in series #2388

Merged
merged 3 commits into from
Aug 23, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: create HTTP servers in series
In Windows this consistently fails because of port collisions when using ethemeral ports.

License: MIT
Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
Alan Shaw committed Aug 23, 2019

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 79d2e696d781b22c0e9c3ee23e1ae9e1ce3c1b08
10 changes: 5 additions & 5 deletions src/http/index.js
Original file line number Diff line number Diff line change
@@ -23,20 +23,20 @@ function hapiInfoToMultiaddr (info) {
return toMultiaddr(uri)
}

function serverCreator (serverAddrs, createServer, ipfs) {
async function serverCreator (serverAddrs, createServer, ipfs) {
serverAddrs = serverAddrs || []
// just in case the address is just string
serverAddrs = Array.isArray(serverAddrs) ? serverAddrs : [serverAddrs]

const processServer = async address => {
const servers = []
for (const address of serverAddrs) {
const addrParts = address.split('/')
const server = await createServer(addrParts[2], addrParts[4], ipfs)
await server.start()
server.info.ma = hapiInfoToMultiaddr(server.info)
return server
servers.push(server)
}

return Promise.all(serverAddrs.map(processServer))
return servers
}

class HttpApi {