| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,7 +23,12 @@ ObjectSetPrototypeOf(SyncWriteStream.prototype, Writable.prototype); | |||
| 23 | 23 | ObjectSetPrototypeOf(SyncWriteStream, Writable); | |
| 24 | 24 | ||
| 25 | 25 | SyncWriteStream.prototype._write = function(chunk, encoding, cb) { | |
| 26 | - writeSync(this.fd, chunk, 0, chunk.length); | ||
| 26 | + try { | ||
| 27 | + writeSync(this.fd, chunk, 0, chunk.length); | ||
| 28 | + } catch (e) { | ||
| 29 | + cb(e); | ||
| 30 | + return; | ||
| 31 | + } | ||
| 27 | 32 | cb(); | |
| 28 | 33 | }; | |
| 29 | 34 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -79,3 +79,15 @@ const filename = path.join(tmpdir.path, 'sync-write-stream.txt'); | |||
| 79 | 79 | assert.strictEqual(stream.fd, null); | |
| 80 | 80 | })); | |
| 81 | 81 | } | |
| 82 | + | ||
| 83 | + // Verify that an error on _write() triggers an 'error' event. | ||
| 84 | + { | ||
| 85 | + const fd = fs.openSync(filename, 'w'); | ||
| 86 | + const stream = new SyncWriteStream(fd); | ||
| 87 | + | ||
| 88 | + assert.strictEqual(stream.fd, fd); | ||
| 89 | + stream._write({}, null, common.mustCall((err) => { | ||
| 90 | + assert(err); | ||
| 91 | + fs.closeSync(fd); | ||
| 92 | + })); | ||
| 93 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments