Skip to content

Commit 0dec568

Browse files
ChALkeRMylesBorins
authored andcommitted
fs: remove broken code in promises/write
That code expects the last argument to be a callback. When it's not a callback, it shifts arguments, defaulting encoding to 'utf-8', which is clearly broken. Old signature: (fd, string[, position[, encoding]], callback) New signature: (fd, string[, position[, encoding]]) PR-URL: #20407 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Jamie Davis <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
1 parent b172f6b commit 0dec568

File tree

1 file changed

+0
-9
lines changed

1 file changed

+0
-9
lines changed

lib/internal/fs/promises.js

-9
Original file line numberDiff line numberDiff line change
@@ -242,15 +242,6 @@ async function write(handle, buffer, offset, length, position) {
242242

243243
if (typeof buffer !== 'string')
244244
buffer += '';
245-
if (typeof position !== 'function') {
246-
if (typeof offset === 'function') {
247-
position = offset;
248-
offset = null;
249-
} else {
250-
position = length;
251-
}
252-
length = 'utf8';
253-
}
254245
const bytesWritten = (await binding.writeString(handle.fd, buffer, offset,
255246
length, kUsePromises)) || 0;
256247
return { bytesWritten, buffer };

0 commit comments

Comments
 (0)