Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
szmarczak committed Aug 5, 2019
1 parent 67deaae commit 419ab56
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions source/agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ class Agent extends EventEmitter {

const entry = () => {
try {
const name = `${normalizedAuthority}:${normalizedOptions}`;
let receivedSettings = false;

const session = http2.connect(authority, {
Expand Down
17 changes: 9 additions & 8 deletions test/agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,8 @@ if (isCompatible) {
});

test('`closeFreeSessions()` closes sessions with 0 pending streams only', wrapper, async (t, server) => {
const agent = new Agent();

{
const agent = new Agent();
const session = await agent.getSession(server.url);

agent.closeFreeSessions();
Expand All @@ -233,13 +232,13 @@ if (isCompatible) {
}

{
const agent = new Agent();
const session = await agent.getSession(server.url);
(await agent.request(server.url)).end();

agent.closeFreeSessions();

t.is(session.closed, false);

t.is(Object.values(agent.freeSessions).length, 1);
}
});
Expand Down Expand Up @@ -313,7 +312,9 @@ if (isCompatible) {
t.is(session.socket.servername, 'foobar');
});

test('appends to freeSessions after the stream has ended', singleRequestWrapper, async (t, server) => {
// Blocking: https://github.com/nodejs/node/issues/28985
// eslint-disable-next-line ava/no-skip-test
test.skip('appends to freeSessions after the stream has ended', singleRequestWrapper, async (t, server) => {
t.plan(1);

server.get('/', (request, response) => {
Expand Down Expand Up @@ -383,13 +384,13 @@ if (isCompatible) {
const agent = new Agent();
await agent.getSession(server.url);

t.true(is.buffer(agent.tlsSessionCache.get(agent.getName(server.url))));
t.true(is.buffer(agent.tlsSessionCache.get(`${agent.normalizeAuthority(server.url)}:`)));
});

test('reuses a TLS session', wrapper, async (t, server) => {
const agent = new Agent();
const session = await agent.getSession(server.url);
const tlsSession = agent.tlsSessionCache.get(agent.getName(server.url));
const tlsSession = agent.tlsSessionCache.get(`${agent.normalizeAuthority(server.url)}:`);

session.close();
await pEvent(session, 'close');
Expand All @@ -403,12 +404,12 @@ if (isCompatible) {
test('purges the TLS session on session error', wrapper, async (t, server) => {
const agent = new Agent();
const session = await agent.getSession(server.url);
t.true(is.buffer(agent.tlsSessionCache.get(agent.getName(server.url))));
t.true(is.buffer(agent.tlsSessionCache.get(`${agent.normalizeAuthority(server.url)}:`)));

session.destroy(new Error('Ouch.'));
await pEvent(session, 'close', {rejectionEvents: []});

t.true(is.undefined(agent.tlsSessionCache.get(agent.getName(server.url))));
t.true(is.undefined(agent.tlsSessionCache.get(`${agent.normalizeAuthority(server.url)}:`)));
});
}

Expand Down

0 comments on commit 419ab56

Please sign in to comment.