GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Forget closed http2 streams by davedoesdev · Pull Request #23134 · nodejs/node

Forget closed http2 streams #23134

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.

Sign up for GitHub

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

Closed
davedoesdev wants to merge 4 commits into nodejs:master from davedoesdev:issue-23116-forget-closed-http2-streams

Uh oh!

There was an error while loading. Please reload this page.

Closed

Forget closed http2 streams #23134

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
4 commits
Select commit Hold shift + click to select a range
f6642cf
Forget closed http2 streams
davedoesdev Sep 27, 2018
7507015
Add comment explaining call to nghttp2_option_set_no_closed_streams
davedoesdev Sep 27, 2018
6467dc1
Issue #23116: Decrease test run time
davedoesdev Sep 28, 2018
4a7367f
Use resume to consume stream in test
davedoesdev Oct 2, 2018
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

4 changes: 4 additions & 0 deletions 4 src/node_http2.cc
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ Http2Scope::~Http2Scope() {
Http2Options::Http2Options(Environment* env, nghttp2_session_type type) {
nghttp2_option_new(&options_);

// Make sure closed connections aren't kept around, taking up memory.
// Note that this breaks the priority tree, which we don't use.
nghttp2_option_set_no_closed_streams(options_, 1);

// We manually handle flow control within a session in order to
// implement backpressure -- that is, we only send WINDOW_UPDATE
// frames to the remote peer as data is actually consumed by user
Expand Down
53 changes: 53 additions & 0 deletions 53 test/parallel/test-http2-forget-closed-streams.js
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
'use strict';
const common = require('../common');
if (!common.hasCrypto) {
common.skip('missing crypto');
}

// Issue #23116
// nghttp2 keeps closed stream structures around in memory (couple of hundred
// bytes each) until a session is closed. It does this to maintain the priority
// tree. However, it limits the number of requests that can be made in a
// session before our memory tracking (correctly) kicks in.
// The fix is to tell nghttp2 to forget about closed streams. We don't make use
// of priority anyway.
// Without the fix, this test fails at ~40k requests with an exception:
// Error [ERR_HTTP2_STREAM_ERROR]: Stream closed with error code
// NGHTTP2_ENHANCE_YOUR_CALM

const http2 = require('http2');
const assert = require('assert');

const server = http2.createServer({ maxSessionMemory: 1 });

server.on('session', function(session) {
session.on('stream', function(stream) {
stream.on('end', common.mustCall(function() {
this.respond({
':status': 200
}, {
endStream: true
});
}));
stream.resume();
});
});

server.listen(0, function() {
const client = http2.connect(`http://localhost:${server.address().port}`);

function next(i) {
if (i === 10000) {
client.close();
return server.close();
}
const stream = client.request({ ':method': 'POST' });
stream.on('response', common.mustCall(function(headers) {
assert.strictEqual(headers[':status'], 200);
this.on('close', common.mustCall(() => next(i + 1)));
}));
stream.end();
}

next(0);
});
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.