From c3a27d1d3dbd2ad9f207aac4c8fa3ba35696395e Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Mon, 26 Jun 2023 11:01:35 +0200 Subject: [PATCH] fs: remove unneeded return statement The `writable._write()` implementation does not need to return anything, only call the callback. PR-URL: https://github.com/nodejs/node/pull/48526 Reviewed-By: Keyhan Vakil Reviewed-By: Debadree Chatterjee Reviewed-By: Deokjin Kim --- lib/internal/fs/sync_write_stream.js | 1 - test/parallel/test-internal-fs-syncwritestream.js | 7 ++++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/internal/fs/sync_write_stream.js b/lib/internal/fs/sync_write_stream.js index 8fa5c56aaffc62..5fff43f43a76c9 100644 --- a/lib/internal/fs/sync_write_stream.js +++ b/lib/internal/fs/sync_write_stream.js @@ -25,7 +25,6 @@ ObjectSetPrototypeOf(SyncWriteStream, Writable); SyncWriteStream.prototype._write = function(chunk, encoding, cb) { writeSync(this.fd, chunk, 0, chunk.length); cb(); - return true; }; SyncWriteStream.prototype._destroy = function(err, cb) { diff --git a/test/parallel/test-internal-fs-syncwritestream.js b/test/parallel/test-internal-fs-syncwritestream.js index bafa5fd8f4624f..b93d3f01d875ee 100644 --- a/test/parallel/test-internal-fs-syncwritestream.js +++ b/test/parallel/test-internal-fs-syncwritestream.js @@ -36,7 +36,12 @@ const filename = path.join(tmpdir.path, 'sync-write-stream.txt'); const stream = new SyncWriteStream(fd); const chunk = Buffer.from('foo'); - assert.strictEqual(stream._write(chunk, null, common.mustCall(1)), true); + let calledSynchronously = false; + stream._write(chunk, null, common.mustCall(() => { + calledSynchronously = true; + }, 1)); + + assert.ok(calledSynchronously); assert.strictEqual(fs.readFileSync(filename).equals(chunk), true); fs.closeSync(fd);