Skip to content

Commit 7f81e96

Browse files
committed
chore: use maxSockets:1 for some flaky arborist reify tests
1 parent fb31c7e commit 7f81e96

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

workspaces/arborist/test/arborist/reify.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ const {
127127
stop,
128128
registry,
129129
advisoryBulkResponse,
130+
oneSocket,
130131
} = require('../fixtures/server.js')
131132

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

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

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

14181419
t.test('reify properly with all deps when lockfile is ancient', async t => {
14191420
const path = fixture(t, 'sax')
1420-
const tree = await reify(path)
1421+
const tree = await reify(path, oneSocket(t))
14211422
t.matchSnapshot(printTree(tree))
14221423
fs.statSync(path + '/node_modules/tap/node_modules/.bin/nyc')
14231424
})

workspaces/arborist/test/fixtures/server.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,18 @@ exports.registry = `http://localhost:${PORT}/`
241241
exports.start = startServer
242242
exports.stop = () => exports.server.close()
243243

244+
exports.oneSocket = (t) => {
245+
t.comment('using http.Agent with maxSockets:1, this is a hack that should be fixed')
246+
// work around an unknown issue for know where agents on localhost need a
247+
// low maxSockets to avoid ECONNRESET issues when dealing with ipv4 and ipv6
248+
// dns resolution (i think)
249+
return {
250+
agent: new http.Agent({
251+
maxSockets: 1,
252+
}),
253+
}
254+
}
255+
244256
if (require.main === module) {
245257
startServer()
246258
.then(() => console.log(`Mock registry live at:\n${exports.registry}\nPress ^D to close gracefully.`))

0 commit comments

Comments
 (0)