mirror of
https://github.com/nodejs/node.git
synced 2025-05-10 11:50:36 +00:00

PR-URL: https://github.com/nodejs/node/pull/20504 Refs: https://github.com/nodejs/TSC/issues/389 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Shingo Inoue <leko.noor@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
30 lines
778 B
JavaScript
30 lines
778 B
JavaScript
// Flags: --expose-gc --no-warnings --expose-internals
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const path = require('path');
|
|
const fs = process.binding('fs');
|
|
const { stringToFlags } = require('internal/fs/utils');
|
|
|
|
// Verifies that the FileHandle object is garbage collected and that a
|
|
// warning is emitted if it is not closed.
|
|
|
|
let fdnum;
|
|
{
|
|
const ctx = {};
|
|
fdnum = fs.openFileHandle(path.toNamespacedPath(__filename),
|
|
stringToFlags('r'), 0o666, undefined, ctx).fd;
|
|
assert.strictEqual(ctx.errno, undefined);
|
|
}
|
|
|
|
common.expectWarning(
|
|
'Warning',
|
|
`Closing file descriptor ${fdnum} on garbage collection`,
|
|
common.noWarnCode
|
|
);
|
|
|
|
gc(); // eslint-disable-line no-undef
|
|
|
|
setTimeout(() => {}, 10);
|