Skip to content

Commit

Permalink
checkpoint: remove nodeerror (30%)
Browse files Browse the repository at this point in the history
  • Loading branch information
RafaelGSS committed Dec 30, 2022
1 parent 0639cf7 commit ecd6065
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
24 changes: 12 additions & 12 deletions lib/internal/webstreams/readablestream.js
Original file line number Diff line number Diff line change
Expand Up @@ -2027,10 +2027,10 @@ function readableStreamReaderGenericInitialize(reader, stream) {

function readableStreamDefaultReaderRelease(reader) {
readableStreamReaderGenericRelease(reader);
readableStreamDefaultReaderErrorReadRequests(
reader,
new ERR_INVALID_STATE.TypeError('Releasing reader')
);
// readableStreamDefaultReaderErrorReadRequests(
// reader,
// new ERR_INVALID_STATE.TypeError('Releasing reader')
// );
}

function readableStreamDefaultReaderErrorReadRequests(reader, e) {
Expand Down Expand Up @@ -2063,15 +2063,15 @@ function readableStreamReaderGenericRelease(reader) {
assert(stream[kState].reader === reader);

if (stream[kState].state === 'readable') {
reader[kState].close.reject?.(
new ERR_INVALID_STATE.TypeError('Reader released'));
// reader[kState].close.reject?.(
// new ERR_INVALID_STATE.TypeError('Reader released'));
} else {
reader[kState].close = {
promise: PromiseReject(
new ERR_INVALID_STATE.TypeError('Reader released')),
resolve: undefined,
reject: undefined,
};
// reader[kState].close = {
// promise: PromiseReject(
// new ERR_INVALID_STATE.TypeError('Reader released')),
// resolve: undefined,
// reject: undefined,
// };
}
setPromiseHandled(reader[kState].close.promise);

Expand Down
7 changes: 3 additions & 4 deletions lib/internal/webstreams/writablestream.js
Original file line number Diff line number Diff line change
Expand Up @@ -970,10 +970,9 @@ function writableStreamDefaultWriterRelease(writer) {
} = writer[kState];
assert(stream !== undefined);
assert(stream[kState].writer === writer);
const releasedError =
new ERR_INVALID_STATE.TypeError('Writer has been released');
writableStreamDefaultWriterEnsureReadyPromiseRejected(writer, releasedError);
writableStreamDefaultWriterEnsureClosedPromiseRejected(writer, releasedError);
// const releasedError =
// new ERR_INVALID_STATE.TypeError('Writer has been released'); writableStreamDefaultWriterEnsureReadyPromiseRejected(writer, releasedError);
// writableStreamDefaultWriterEnsureClosedPromiseRejected(writer, releasedError);
stream[kState].writer = undefined;
writer[kState].stream = undefined;
}
Expand Down

2 comments on commit ecd6065

@ronag
Copy link

@ronag ronag commented on ecd6065 Jan 3, 2023

Choose a reason for hiding this comment

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

What if we pre-allocate an Error instance and re-use it?

@RafaelGSS
Copy link
Owner Author

@RafaelGSS RafaelGSS commented on ecd6065 Jan 3, 2023

Choose a reason for hiding this comment

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

I'll do it. I'm not quite sure about its security impacts, but it's worth it to try.

Please sign in to comment.