Skip to content
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.

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

v14.10.1 proposal #35137

Merged
merged 3 commits into from
Sep 10, 2020
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ release.
</tr>
<tr>
<td valign="top">
<b><a href="doc/changelogs/CHANGELOG_V14.md#14.10.0">14.10.0</a></b><br/>
<b><a href="doc/changelogs/CHANGELOG_V14.md#14.10.1">14.10.1</a></b><br/>
<a href="doc/changelogs/CHANGELOG_V14.md#14.10.0">14.10.0</a><br/>
<a href="doc/changelogs/CHANGELOG_V14.md#14.9.0">14.9.0</a><br/>
<a href="doc/changelogs/CHANGELOG_V14.md#14.8.0">14.8.0</a><br/>
<a href="doc/changelogs/CHANGELOG_V14.md#14.7.0">14.7.0</a><br/>
Expand Down
38 changes: 0 additions & 38 deletions benchmark/streams/readable-async-iterator.js

This file was deleted.

3 changes: 2 additions & 1 deletion doc/api_assets/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ a.type {
}

a:link,
a:active {
a:active,
a:visited {
color: #43853d;
text-decoration: none;
border-radius: 2px;
Expand Down
14 changes: 14 additions & 0 deletions doc/changelogs/CHANGELOG_V14.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
</tr>
<tr>
<td>
<a href="#14.10.1">14.10.1</a><br/>
<a href="#14.10.0">14.10.0</a><br/>
<a href="#14.9.0">14.9.0</a><br/>
<a href="#14.8.0">14.8.0</a><br/>
Expand Down Expand Up @@ -41,6 +42,19 @@
* [io.js](CHANGELOG_IOJS.md)
* [Archive](CHANGELOG_ARCHIVE.md)

<a id="14.10.1"></a>
## 2020-09-10, Version 14.10.1 (Current), @richardlau

### Notable Changes

Node.js 14.10.0 included a streams regression with async generators
and a docs rendering regression that are being fixed in this release.

### Commits

* [[`3c92f93b44`](https://github.com/nodejs/node/commit/3c92f93b44)] - **doc**: restore color for visited links (Rich Trott) [#35108](https://github.com/nodejs/node/pull/35108)
* [[`0f94c6b4e4`](https://github.com/nodejs/node/commit/0f94c6b4e4)] - ***Revert*** "**stream**: simpler and faster Readable async iterator" (Richard Lau)

<a id="14.10.0"></a>
## 2020-09-08, Version 14.10.0 (Current), @richardlau

Expand Down
66 changes: 5 additions & 61 deletions lib/_stream_readable.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const {
NumberIsNaN,
ObjectDefineProperties,
ObjectSetPrototypeOf,
Promise,
Set,
SymbolAsyncIterator,
Symbol
Expand Down Expand Up @@ -60,11 +59,11 @@ const kPaused = Symbol('kPaused');

// Lazy loaded to improve the startup performance.
let StringDecoder;
let createReadableStreamAsyncIterator;
let from;

ObjectSetPrototypeOf(Readable.prototype, Stream.prototype);
ObjectSetPrototypeOf(Readable, Stream);
function nop() {}

const { errorOrDestroy } = destroyImpl;

Expand Down Expand Up @@ -1076,68 +1075,13 @@ Readable.prototype.wrap = function(stream) {
};

Readable.prototype[SymbolAsyncIterator] = function() {
let stream = this;

if (typeof stream.read !== 'function') {
// v1 stream
const src = stream;
stream = new Readable({
objectMode: true,
destroy(err, callback) {
destroyImpl.destroyer(src, err);
callback();
}
}).wrap(src);
if (createReadableStreamAsyncIterator === undefined) {
createReadableStreamAsyncIterator =
require('internal/streams/async_iterator');
}

const iter = createAsyncIterator(stream);
iter.stream = stream;
return iter;
return createReadableStreamAsyncIterator(this);
};

async function* createAsyncIterator(stream) {
let callback = nop;

function next(resolve) {
if (this === stream) {
callback();
callback = nop;
} else {
callback = resolve;
}
}

stream
.on('readable', next)
.on('error', next)
.on('end', next)
.on('close', next);

try {
const state = stream._readableState;
while (true) {
const chunk = stream.read();
if (chunk !== null) {
yield chunk;
} else if (state.errored) {
throw state.errored;
} else if (state.ended) {
break;
} else if (state.closed) {
// TODO(ronag): ERR_PREMATURE_CLOSE?
break;
} else {
await new Promise(next);
}
}
} catch (err) {
destroyImpl.destroyer(stream, err);
throw err;
} finally {
destroyImpl.destroyer(stream, null);
}
}

// Making it explicit these properties are not enumerable
// because otherwise some prototype manipulation in
// userland will fail.
Expand Down
Loading