Skip to content
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

test: deflake test-tls-js-stream #27478

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions test/parallel/parallel.status
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ test-http2-client-upload-reject: PASS,FLAKY
[$system==linux]

[$system==macos]
# https://github.com/nodejs/node/issues/26938
test-tls-js-stream: PASS,FLAKY

[$arch==arm || $arch==arm64]
# https://github.com/nodejs/node/issues/26610
Expand Down
33 changes: 12 additions & 21 deletions test/parallel/test-tls-js-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,19 @@ if (!common.hasCrypto)

const fixtures = require('../common/fixtures');

const assert = require('assert');
const net = require('net');
const stream = require('stream');
const tls = require('tls');

const connected = {
client: 0,
server: 0
};

const server = tls.createServer({
key: fixtures.readKey('agent1-key.pem'),
cert: fixtures.readKey('agent1-cert.pem')
}, function(c) {
}, common.mustCall(function(c) {
console.log('new client');
connected.server++;

c.resume();
c.end('ohai');
}).listen(0, function() {
})).listen(0, common.mustCall(function() {
const raw = net.connect(this.address().port);

let pending = false;
Expand All @@ -32,6 +27,10 @@ const server = tls.createServer({
p._read();
});

raw.on('end', function() {
p.push(null);
});

const p = new stream.Duplex({
read: function read() {
pending = false;
Expand All @@ -53,23 +52,15 @@ const server = tls.createServer({
const socket = tls.connect({
socket: p,
rejectUnauthorized: false
}, function() {
}, common.mustCall(function() {
console.log('client secure');

connected.client++;

socket.end('hello');
socket.resume();
socket.destroy();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reference this was added in 75930bb#diff-94e518e66d7d1b91e52af17401305431.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's placement was a deliberate regression test for destroy() in an SSL cb (specifically, from js code executed during a callback from an SSL C++ cb), so removing it loses the regression test. But, the general purpose of this test for js streams, not destroy-in-cb, and it looks like the two tests don't fit comfortably together anymore. It would be good to have a new test that triggers the old bug, but maybe at this point, with the bug fixed, we can afford to lose this line. If not, we likely need a new test specifcally for the destroy that doesn't depend on the rest of the test working.

});
socket.end('hello');
}));

socket.once('close', function() {
console.log('client close');
server.close();
});
});

process.once('exit', function() {
assert.strictEqual(connected.client, 1);
assert.strictEqual(connected.server, 1);
});
}));