Skip to content
Closed
Changes from all commits
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
13 changes: 8 additions & 5 deletions lib/_http_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
startPerf,
stopPerf,
} = require('internal/perf/observe');
const FixedQueue = require('internal/fixed_queue');

const STATUS_CODES = {
100: 'Continue', // RFC 7231 6.2.1
Expand Down Expand Up @@ -724,7 +725,7 @@
onClose: null,
onDrain: null,
outgoing: [],
incoming: [],
incoming: new FixedQueue(),
// `outgoingData` is an approximate amount of bytes queued through all
// inactive responses. If more data than the high watermark is queued - we
// need to pause TCP socket/HTTP parser, and wait until the data will be
Expand Down Expand Up @@ -822,7 +823,7 @@
}

function abortIncoming(incoming) {
while (incoming.length) {
while (!incoming.isEmpty()) {
const req = incoming.shift();
req.destroy(new ConnResetException('aborted'));
}
Expand Down Expand Up @@ -1003,12 +1004,14 @@
});
}

const head = state.incoming.shift();

// Usually the first incoming element should be our request. it may
// be that in the case abortIncoming() was called that the incoming
// array will be empty.
assert(state.incoming.length === 0 || state.incoming[0] === req);

state.incoming.shift();
if (head !== null && head !== req) {
throw new Error('Out of order response finish');

Check failure on line 1013 in lib/_http_server.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Use an error exported by 'internal/errors' instead
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a proper node.js error with a code property

}

// If the user never called req.read(), and didn't pipe() or
// .resume() or .on('data'), then we call req._dump() so that the
Expand Down
Loading