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 — net,http2: merge write error handling & property names · nodejs/node@e85c20b

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib
    • internal
      • http2
        • core.js
      • stream_base_commons.js
    • net.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/http2/core.js‎

Copy file name to clipboardExpand all lines: lib/internal/http2/core.js
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1657,7 +1657,6 @@ class Http2Stream extends Duplex {
16571657

16581658
const req = createWriteWrap(this[kHandle], afterDoStreamWrite);
16591659
req.stream = this[kID];
1660-
req.callback = cb;
16611660

16621661
writeGeneric(this, req, data, encoding, cb);
16631662

@@ -1690,7 +1689,6 @@ class Http2Stream extends Duplex {
16901689

16911690
var req = createWriteWrap(this[kHandle], afterDoStreamWrite);
16921691
req.stream = this[kID];
1693-
req.callback = cb;
16941692

16951693
writevGeneric(this, req, data, cb);
16961694

Collapse file

‎lib/internal/stream_base_commons.js‎

Copy file name to clipboardExpand all lines: lib/internal/stream_base_commons.js
+12-3Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,24 @@ function writevGeneric(self, req, data, cb) {
6161
// Retain chunks
6262
if (err === 0) req._chunks = chunks;
6363

64-
if (err)
65-
return self.destroy(errnoException(err, 'write', req.error), cb);
64+
afterWriteDispatched(self, req, err, cb);
6665
}
6766

6867
function writeGeneric(self, req, data, encoding, cb) {
6968
var err = handleWriteReq(req, data, encoding);
7069

71-
if (err)
70+
afterWriteDispatched(self, req, err, cb);
71+
}
72+
73+
function afterWriteDispatched(self, req, err, cb) {
74+
if (err !== 0)
7275
return self.destroy(errnoException(err, 'write', req.error), cb);
76+
77+
if (!req.async) {
78+
cb();
79+
} else {
80+
req.callback = cb;
81+
}
7382
}
7483

7584
module.exports = {
Collapse file

‎lib/net.js‎

Copy file name to clipboardExpand all lines: lib/net.js
+7-17Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -754,23 +754,13 @@ Socket.prototype._writeGeneric = function(writev, data, encoding, cb) {
754754
return false;
755755
}
756756

757-
var ret;
758757
var req = createWriteWrap(this._handle, afterWrite);
759758
if (writev)
760-
ret = writevGeneric(this, req, data, cb);
759+
writevGeneric(this, req, data, cb);
761760
else
762-
ret = writeGeneric(this, req, data, encoding, cb);
763-
764-
// Bail out if handle.write* returned an error
765-
if (ret) return ret;
766-
767-
if (!req.async) {
768-
cb();
769-
return;
770-
}
771-
772-
req.cb = cb;
773-
this[kLastWriteQueueSize] = req.bytes;
761+
writeGeneric(this, req, data, encoding, cb);
762+
if (req.async)
763+
this[kLastWriteQueueSize] = req.bytes;
774764
};
775765

776766

@@ -845,7 +835,7 @@ function afterWrite(status, handle, err) {
845835
if (status < 0) {
846836
var ex = errnoException(status, 'write', this.error);
847837
debug('write failure', ex);
848-
self.destroy(ex, this.cb);
838+
self.destroy(ex, this.callback);
849839
return;
850840
}
851841

@@ -854,8 +844,8 @@ function afterWrite(status, handle, err) {
854844
if (self !== process.stderr && self !== process.stdout)
855845
debug('afterWrite call cb');
856846

857-
if (this.cb)
858-
this.cb.call(undefined);
847+
if (this.callback)
848+
this.callback.call(undefined);
859849
}
860850

861851

0 commit comments

Comments
0 (0)
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.