Skip to content

fix(ext/node): TLSSocket.setServername throws typed errors#33744

Merged
bartlomieju merged 1 commit into
denoland:mainfrom
fibibot:fix/tls-setservername-arg-type
May 3, 2026
Merged

fix(ext/node): TLSSocket.setServername throws typed errors#33744
bartlomieju merged 1 commit into
denoland:mainfrom
fibibot:fix/tls-setservername-arg-type

Conversation

@fibibot

@fibibot fibibot commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

Summary

TLSSocket.prototype.setServername in ext/node/polyfills/_tls_wrap.js threw plain TypeError/Error without the code property that Node.js attaches. User code and Node test suites that branch on err.code couldn't distinguish these errors.

Replace with the existing ERR_INVALID_ARG_TYPE and ERR_TLS_SNI_FROM_SERVER Node-compat error classes from internal/errors.ts (the latter was already defined there but unused).

Closes #33743.

Test plan

  • New TLSSocket.setServername - throws ERR_INVALID_ARG_TYPE for non-string test in tests/unit_node/tls_test.ts asserts err.name === "TypeError" and err.code === "ERR_INVALID_ARG_TYPE"
  • New TLSSocket.setServername - throws ERR_TLS_SNI_FROM_SERVER on server-side socket test asserts err.code === "ERR_TLS_SNI_FROM_SERVER"
  • Both pass locally

`TLSSocket.prototype.setServername` threw plain `TypeError`/`Error`
without the `code` property that Node attaches. Replace with the
existing `ERR_INVALID_ARG_TYPE` and `ERR_TLS_SNI_FROM_SERVER` Node-
compat error classes (the latter was already defined in
`internal/errors.ts`, just not used here).

Fixes denoland#33743.
@bartlomieju
bartlomieju merged commit 81a7724 into denoland:main May 3, 2026
136 checks passed
littledivy pushed a commit to crowlKats/deno that referenced this pull request Jun 10, 2026
…33744)

`TLSSocket.prototype.setServername` in `ext/node/polyfills/_tls_wrap.js`
threw plain `TypeError`/`Error` without the `code` property that Node.js
attaches. User code and Node test suites that branch on `err.code`
couldn't distinguish these errors.

Replace with the existing `ERR_INVALID_ARG_TYPE` and
`ERR_TLS_SNI_FROM_SERVER` Node-compat error classes from
`internal/errors.ts` (the latter was already defined there but unused).

Closes denoland#33743
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.

tls.TLSSocket.setServername() throws wrong error types (missing .code)

2 participants