Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 36.4k
Net: Defer reading until listeners could be added#1496
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| 'use strict'; | ||
| var common = require('../common'); | ||
| var assert = require('assert'); | ||
| if (!common.hasCrypto) { | ||
| console.log('1..0 # Skipped: missing crypto'); | ||
| process.exit(); | ||
| } | ||
| var tls = require('tls'); | ||
| var fs = require('fs'); | ||
| var net = require('net'); | ||
| var bonkers = new Buffer(1024); | ||
| bonkers.fill(42); | ||
| var receivedError = false; | ||
| var options = { | ||
| key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'), | ||
| cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem') | ||
| }; | ||
| var server = net.createServer(function(c) { | ||
| setTimeout(function() { | ||
| var s = new tls.TLSSocket(c, { | ||
| isServer: true, | ||
| secureContext: tls.createSecureContext(options) | ||
| }); | ||
| s.on('_tlsError', function() { | ||
| receivedError = true; | ||
| }); | ||
| s.on('close', function() { | ||
| server.close(); | ||
| s.destroy(); | ||
| }); | ||
| }, 200); | ||
| }).listen(common.PORT, function() { | ||
| var c = net.connect({port: common.PORT}, function() { | ||
| c.write(bonkers); | ||
| }); | ||
| }); | ||
| process.on('exit', function() { | ||
| assert.ok(receivedError); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -13,7 +13,6 @@ var net = require('net'); | ||
| var sent = 'hello world'; | ||
| var received = ''; | ||
| var ended = 0; | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why? ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See #1496 (comment) | ||
| var options = { | ||
| key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'), | ||
| @@ -32,7 +31,6 @@ var server = net.createServer(function(c) { | ||
| }); | ||
| s.on('end', function() { | ||
| ended++; | ||
| server.close(); | ||
| s.destroy(); | ||
| }); | ||
| @@ -47,5 +45,4 @@ var server = net.createServer(function(c) { | ||
| process.on('exit', function() { | ||
| assert.equal(received, sent); | ||
| assert.equal(ended, 1); | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A
'use strict';now needs to be added here with the new linter.