Skip to content

Commit

Permalink
chore: use maxSockets:1 for some flaky arborist reify tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lukekarrys committed Aug 31, 2023
1 parent fb31c7e commit 7f81e96
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 3 additions & 2 deletions workspaces/arborist/test/arborist/reify.js
Expand Up @@ -127,6 +127,7 @@ const {
stop,
registry,
advisoryBulkResponse,
oneSocket,
} = require('../fixtures/server.js')

t.before(start)
Expand Down Expand Up @@ -170,7 +171,7 @@ t.test('update a yarn.lock file', async t => {
})

t.test('weirdly broken lockfile without resolved value', t =>
t.resolveMatchSnapshot(printReified(fixture(t, 'dep-missing-resolved'))))
t.resolveMatchSnapshot(printReified(fixture(t, 'dep-missing-resolved'), oneSocket(t))))

t.test('testing-peer-deps package', t =>
t.resolveMatchSnapshot(printReified(fixture(t, 'testing-peer-deps'))))
Expand Down Expand Up @@ -1417,7 +1418,7 @@ t.test('do not reify root when root matches duplicated metadep', async t => {

t.test('reify properly with all deps when lockfile is ancient', async t => {
const path = fixture(t, 'sax')
const tree = await reify(path)
const tree = await reify(path, oneSocket(t))
t.matchSnapshot(printTree(tree))
fs.statSync(path + '/node_modules/tap/node_modules/.bin/nyc')
})
Expand Down
12 changes: 12 additions & 0 deletions workspaces/arborist/test/fixtures/server.js
Expand Up @@ -241,6 +241,18 @@ exports.registry = `http://localhost:${PORT}/`
exports.start = startServer
exports.stop = () => exports.server.close()

exports.oneSocket = (t) => {
t.comment('using http.Agent with maxSockets:1, this is a hack that should be fixed')
// work around an unknown issue for know where agents on localhost need a
// low maxSockets to avoid ECONNRESET issues when dealing with ipv4 and ipv6
// dns resolution (i think)
return {
agent: new http.Agent({
maxSockets: 1,
}),
}
}

if (require.main === module) {
startServer()
.then(() => console.log(`Mock registry live at:\n${exports.registry}\nPress ^D to close gracefully.`))
Expand Down

0 comments on commit 7f81e96

Please sign in to comment.