Skip to content

Commit 76f6702

Browse files
authored
fix(ext/node): tls upgrades for used sockets (#659)
1 parent eecbf11 commit 76f6702

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

ext/node/polyfills/internal_binding/stream_wrap.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,11 @@
3030
// TODO(petamoriken): enable prefer-primordials for node polyfills
3131
// deno-lint-ignore-file prefer-primordials
3232

33-
import { core } from "ext:core/mod.js";
33+
import { core, primordials } from "ext:core/mod.js";
3434
const { internalRidSymbol } = core;
35+
const {
36+
PromiseResolve,
37+
} = primordials;
3538
import { op_can_write_vectored, op_raw_write_vectored } from "ext:core/ops";
3639

3740
import { TextEncoder } from "ext:deno_web/08_text_encoding.js";
@@ -319,6 +322,12 @@ export class LibuvStreamWrap extends HandleWrap {
319322

320323
/** Internal method for reading from the attached stream. */
321324
async #read() {
325+
// Queue the read operation and allow TLS upgrades to complete.
326+
//
327+
// This is done to ensure that the resource is not locked up by
328+
// op_read.
329+
await PromiseResolve();
330+
322331
let buf = this.#buf;
323332

324333
let nread: number | null;

0 commit comments

Comments
 (0)