- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 33.6k
Closed
Closed
Copy link
Labels
fsIssues and PRs related to the fs subsystem / file system.Issues and PRs related to the fs subsystem / file system.
Description
- Version: v13.5.0
- Platform: Linux 4.4.0-170-generic Ubuntu SMP Thu Nov 14 01:45:04 UTC 2019 x86_64 GNU/Linux
- Subsystem: fs
Node will abort if filehandle.close() is called after fd is closed by createReadStream.
I am unsure if this "FATAL ERROR" is considered a bug or is expected behavior.
I expected a javascript rejection from fh.close().
stacktrace:
FATAL ERROR: v8::HandleScope::CreateHandle() Cannot create a handle without a HandleScope
 1: 0x9f28f0 node::Abort() [node]
 2: 0x9f4bb2 node::OnFatalError(char const*, char const*) [node]
 3: 0xb5a02a v8::Utils::ReportApiFailure(char const*, char const*) [node]
 4: 0xcd291a v8::internal::HandleScope::Extend(v8::internal::Isolate*) [node]
 5: 0xcf288c v8::internal::Factory::NewRawOneByteString(int, v8::internal::AllocationType) [node]
 6: 0xcf22de v8::internal::Factory::NewStringFromOneByte(v8::internal::Vector<unsigned char const> const&, v8::internal::AllocationType) [node]
 7: 0xb72612 v8::String::NewFromOneByte(v8::Isolate*, unsigned char const*, v8::NewStringType, int) [node]
 8: 0x967d55 node::UVException(v8::Isolate*, int, char const*, char const*, char const*, char const*) [node]
 9: 0x9f6969  [node]
10: 0x1318a45  [node]
11: 0x131cf31  [node]
12: 0x132f7d8  [node]
13: 0x131d8bb uv_run [node]
14: 0xa2fca3 node::NodeMainInstance::Run() [node]
15: 0x9c4511 node::Start(int, char**) [node]
16: 0x7fd1490e6830 __libc_start_main [/lib/x86_64-linux-gnu/libc.so.6]
17: 0x960ea5  [node]
const fs = require("fs");
async function main() {
	const fpath = "./test.txt";	
	const fh = await fs.promises.open(fpath);
	
	const fstream = fs.createReadStream(fpath, {
		fd: fh.fd,
		//autoClose: false, //!!!!prevents the abort
	});
	fstream.on("end", () => {
		fh.close().catch(e => console.error(e)); //node aborts and does not execute javascript catch
	});
	fstream.pipe(process.stdout);
}
main().catch(e => console.error(e));Metadata
Metadata
Assignees
Labels
fsIssues and PRs related to the fs subsystem / file system.Issues and PRs related to the fs subsystem / file system.