Skip to content

Conversation

littledivy
Copy link
Member

Fixes #20594

This implements JSStreamSocket which drives the TLS underlying stream in rustls_tokio_stream using 2 sets of channels. One for piping the encrypted protocol transport and the other for plaintext application data.

This fixes connecting to npm:mssql:

import sql from "npm:mssql";

const sqlConfig = {
  server: "localhost",
  user: "divy",
  password: "123",
  database: "master",
  options: {
    trustServerCertificate: true,
  },
};

const pool = await sql.connect(sqlConfig);
const result = await pool.request().query(`SELECT * FROM sys.databases`);

Comment on lines -31 to -33
disallowed-types = [
{ path = "std::sync::Arc", reason = "use deno_fs::sync::MaybeArc instead" },
]
Copy link
Member

Choose a reason for hiding this comment

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

Is this on purpose?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, the lint rule doesn't help with anything. https://deno-company.slack.com/archives/C03P8NFAJTY/p1755693378481979

Comment on lines +537 to +522
let (network_to_tls_tx, network_to_tls_rx) =
tokio::sync::mpsc::channel::<Bytes>(10);
let (tls_to_network_tx, tls_to_network_rx) =
tokio::sync::mpsc::channel::<Bytes>(10);
Copy link
Member

Choose a reason for hiding this comment

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

Are these totally random buffer sizes?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, it would never have more than 1 message in queue though.

let tls_stream = TlsStream::new_client_side(
js_stream,
ClientConnection::new(tls_config, hostname_dns)?,
NonZeroUsize::new(65536),
Copy link
Member

Choose a reason for hiding this comment

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

Same here, where does this come from?

Copy link
Member Author

Choose a reason for hiding this comment

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

It comes from here:

deno/ext/net/ops_tls.rs

Lines 63 to 64 in c217928

pub(crate) const TLS_BUFFER_SIZE: Option<NonZeroUsize> =
NonZeroUsize::new(65536);

Socket.prototype._unrefTimer = function () {
// deno-lint-ignore no-this-alias
for (let s = this; s !== null; s = s._parent) {
for (let s = this; s != null; s = s._parent) {
Copy link
Member

Choose a reason for hiding this comment

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

Are these unrelated changes?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, _parent can be undefined (not just null) when s is JSStreamSocket

Copy link
Member

Choose a reason for hiding this comment

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

Great, are there any other node compat tests we could enable?

Copy link
Member Author

@littledivy littledivy Aug 28, 2025

Choose a reason for hiding this comment

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

No new tests pass immediately with this PR

@littledivy littledivy force-pushed the jsstreamsocket_fr_pmo branch from 5fdaca8 to 321a52f Compare August 28, 2025 11:48
@littledivy littledivy merged commit 36e9eb2 into denoland:main Aug 28, 2025
19 checks passed
@sant123
Copy link

sant123 commented Aug 28, 2025

Thanks, thanks a lot for this 🙏🏼

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mssql ConnectionError

3 participants