-
Notifications
You must be signed in to change notification settings - Fork 343
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
implement TLSSocket and connect from node:tls #3594
base: main
Are you sure you want to change the base?
Conversation
1fb6373
to
e77192f
Compare
The generated output of |
Nice! |
7968547
to
a8848ab
Compare
5c957db
to
57490be
Compare
b37c0b7
to
ccbf33f
Compare
ccbf33f
to
30b394c
Compare
c098331
to
9e499da
Compare
9e499da
to
7da4321
Compare
7da4321
to
c07f938
Compare
public [kPendingSession]: null | Buffer; | ||
public [kErrorEmitted]: boolean; | ||
public [kDisableRenegotiation]: boolean; | ||
public [kPskCallback]?: TlsOptions['pskCallback']; |
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.
We know that we're not going to be supporting things like renegotiation and pre-shared key callbacks so I'm not sure it makes any sense to include these.
this.on('close', onSocketCloseDestroySSL); | ||
} | ||
|
||
wrap?.on('close', () => this.destroy()); |
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.
once?
// Guard against adding multiple listeners, as this method may be called | ||
// repeatedly on the same socket by reinitializeHandle | ||
if (this.listenerCount('close', onSocketCloseDestroySSL) === 0) { | ||
this.on('close', onSocketCloseDestroySSL); |
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.
once?
// Let's disable floating promises error. | ||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
socket?._handle?.socket.opened.then(this._finishInit.bind(this)); | ||
socket?.on('error', onerror.bind(this)); |
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.
once?
}); | ||
} | ||
|
||
wrap?.on('error', (err: Error): void => { |
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.
once?
this._tlsOptions.handshakeTimeout > 0 | ||
) | ||
this.setTimeout(0, this._handleTimeout.bind(this)); | ||
this.emit('secure'); |
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.
Node.js will often emit events using process.nextTick(...)
to defer execution. Is that needed on these?
// This means that options.host overrides a host arg. | ||
if (listArgs[1] !== null && typeof listArgs[1] === 'object') { | ||
Object.assign(options, listArgs[1]); | ||
} else if (listArgs[2] !== null && typeof listArgs[2] === 'object') { |
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.
Fun fact... you don't need the !== null
check here. Object.assign(options, null)
is handled just fine. In fact, you could get by without any type check here.
this[kIsVerified] = true; | ||
const session = this[kPendingSession]; | ||
this[kPendingSession] = null; | ||
if (session) this.emit('session', session); |
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.
Another one... should these be wrapped in process.nextTick
/queueMicrotask
?
try { | ||
await once(socket, 'close'); | ||
fail(`close ${testName} should have thrown`); | ||
} catch (err) { | ||
strictEqual(err.name, 'AbortError'); | ||
} |
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.
Why not use assert.rejects()
?
It's extremely early to even open this, but people have been asking about the progress, and what better way to show progress than the actual code (with a public pr)