mirror of
https://github.com/nodejs/node.git
synced 2024-11-29 23:16:30 +01:00
fs: add missing HandleScope to FileHandle.close
Fixes: https://github.com/nodejs/node/issues/31202 PR-URL: https://github.com/nodejs/node/pull/31276 Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
parent
be055d103c
commit
679eb3e7d5
@ -301,6 +301,7 @@ MaybeLocal<Promise> FileHandle::ClosePromise() {
|
||||
close->file_handle()->AfterClose();
|
||||
Isolate* isolate = close->env()->isolate();
|
||||
if (req->result < 0) {
|
||||
HandleScope handle_scope(isolate);
|
||||
close->Reject(UVException(isolate, req->result, "close"));
|
||||
} else {
|
||||
close->Resolve();
|
||||
|
17
test/parallel/test-filehandle-close.js
Normal file
17
test/parallel/test-filehandle-close.js
Normal file
@ -0,0 +1,17 @@
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
const assert = require('assert');
|
||||
const fs = require('fs');
|
||||
|
||||
// Test that using FileHandle.close to close an already-closed fd fails
|
||||
// with EBADF.
|
||||
|
||||
(async function() {
|
||||
const fh = await fs.promises.open(__filename);
|
||||
fs.closeSync(fh.fd);
|
||||
|
||||
assert.rejects(() => fh.close(), {
|
||||
code: 'EBADF',
|
||||
syscall: 'close'
|
||||
});
|
||||
})().then(common.mustCall());
|
Loading…
Reference in New Issue
Block a user