-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fs,net: emit 'ready' for fs streams and sockets
... in addition to the event names they currently use. Currently, various internal streams have different events that indicate that the underlying resource has successfully been established. This commit adds ready event for fs and net sockets to standardize on emitting ready for all of these streams. PR-URL: #19408 Fixes: #19304 Reviewed-By: Anna Henningsen <[email protected]>
- Loading branch information
1 parent
84afd6e
commit 1c81494
Showing
4 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const tmpdir = require('../common/tmpdir'); | ||
|
||
const readStream = fs.createReadStream(__filename); | ||
readStream.on('ready', common.mustCall(() => {}, 1)); | ||
|
||
const writeFile = path.join(tmpdir.path, 'write-fsreadyevent.txt'); | ||
tmpdir.refresh(); | ||
const writeStream = fs.createWriteStream(writeFile, { autoClose: true }); | ||
writeStream.on('ready', common.mustCall(() => {}, 1)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
|
||
// This test ensures that socket.connect can be called without callback | ||
// which is optional. | ||
|
||
const net = require('net'); | ||
|
||
const server = net.createServer(common.mustCall(function(conn) { | ||
conn.end(); | ||
server.close(); | ||
})).listen(0, common.mustCall(function() { | ||
const client = new net.Socket(); | ||
|
||
client.on('ready', common.mustCall(function() { | ||
client.end(); | ||
})); | ||
|
||
client.connect(server.address()); | ||
})); |