Repository: nodejs/node
Pull request: fs: remove ability to call truncate with fd

cc @nodejs/tsc since it's a semver-major change.

Changed files:
filename: doc/api/deprecations.md
patch: @@ -1832,12 +1832,15 @@ and replaced with an identical, public `path.toNamespacedPath()` method.
 
 <!-- YAML
 changes:
+  - version: REPLACEME
+    pr-url: https://github.com/nodejs/node/pull/57567
+    description: End-of-Life.
   - version: v9.0.0
     pr-url: https://github.com/nodejs/node/pull/15990
     description: Runtime deprecation.
 -->
 
-Type: Runtime
+Type: End-of-Life
 
 `fs.truncate()` `fs.truncateSync()` usage with a file descriptor is
 deprecated. Please use `fs.ftruncate()` or `fs.ftruncateSync()` to work with

filename: lib/fs.js
patch: @@ -149,7 +149,6 @@ const {
 
 const permission = require('internal/process/permission');
 
-let truncateWarn = true;
 let fs;
 
 // Lazy loaded
@@ -167,16 +166,6 @@ let ReadFileContext;
 let FileReadStream;
 let FileWriteStream;
 
-function showTruncateDeprecation() {
-  if (truncateWarn) {
-    process.emitWarning(
-      'Using fs.truncate with a file descriptor is deprecated. Please use ' +
-      'fs.ftruncate with a file descriptor instead.',
-      'DeprecationWarning', 'DEP0081');
-    truncateWarn = false;
-  }
-}
-
 // Ensure that callbacks run in the global context. Only use this function
 // for callbacks that are passed to the binding layer, callbacks that are
 // invoked from JS already run in the proper scope.
@@ -1031,10 +1020,6 @@ function renameSync(oldPath, newPath) {
  * @returns {void}
  */
 function truncate(path, len, callback) {
-  if (typeof path === 'number') {
-    showTruncateDeprecation();
-    return fs.ftruncate(path, len, callback);
-  }
   if (typeof len === 'function') {
     callback = len;
     len = 0;
@@ -1064,11 +1049,6 @@ function truncate(path, len, callback) {
  * @returns {void}
  */
 function truncateSync(path, len) {
-  if (typeof path === 'number') {
-    // legacy
-    showTruncateDeprecation();
-    return fs.ftruncateSync(path, len);
-  }
   if (len === undefined) {
     len = 0;
   }

filename: test/parallel/test-fs-truncate-fd.js
patch: @@ -1,27 +0,0 @@
-'use strict';
-const common = require('../common');
-const assert = require('assert');
-const path = require('path');
-const fs = require('fs');
-const tmpdir = require('../common/tmpdir');
-const tmp = tmpdir.path;
-tmpdir.refresh();
-const filename = path.resolve(tmp, 'truncate-file.txt');
-
-fs.writeFileSync(filename, 'hello world', 'utf8');
-const fd = fs.openSync(filename, 'r+');
-
-const msg = 'Using fs.truncate with a file descriptor is deprecated.' +
-' Please use fs.ftruncate with a file descriptor instead.';
-
-
-common.expectWarning('DeprecationWarning', msg, 'DEP0081');
-fs.truncate(fd, 5, common.mustSucceed(() => {
-  assert.strictEqual(fs.readFileSync(filename, 'utf8'), 'hello');
-}));
-
-process.once('beforeExit', () => {
-  fs.closeSync(fd);
-  fs.unlinkSync(filename);
-  console.log('ok');
-});

filename: test/parallel/test-fs-truncate-sync.js
patch: @@ -12,10 +12,7 @@ const filename = path.resolve(tmp, 'truncate-sync-file.txt');
 
 fs.writeFileSync(filename, 'hello world', 'utf8');
 
-const fd = fs.openSync(filename, 'r+');
+fs.truncateSync(filename, 5);
+assert(fs.readFileSync(filename).equals(Buffer.from('hello')));
 
-fs.truncateSync(fd, 5);
-assert(fs.readFileSync(fd).equals(Buffer.from('hello')));
-
-fs.closeSync(fd);
 fs.unlinkSync(filename);

filename: test/parallel/test-fs-truncate.js
patch: @@ -33,9 +33,6 @@ tmpdir.refresh();
 
 let stat;
 
-const msg = 'Using fs.truncate with a file descriptor is deprecated.' +
-            ' Please use fs.ftruncate with a file descriptor instead.';
-
 // Check truncateSync
 fs.writeFileSync(filename, data);
 stat = fs.statSync(filename);
@@ -64,10 +61,6 @@ fs.ftruncateSync(fd);
 stat = fs.statSync(filename);
 assert.strictEqual(stat.size, 0);
 
-// truncateSync
-common.expectWarning('DeprecationWarning', msg, 'DEP0081');
-fs.truncateSync(fd);
-
 fs.closeSync(fd);
 
 // Async tests