mirror of
https://github.com/denoland/deno.git
synced 2024-11-28 16:20:57 -05:00
fix(ext/node): avoid showing UNKNOWN
error from TCP handle (#25550)
This commit is contained in:
parent
ad30703e8e
commit
200145a09a
2 changed files with 30 additions and 2 deletions
|
@ -38,6 +38,7 @@ import { TextEncoder } from "ext:deno_web/08_text_encoding.js";
|
||||||
import { Buffer } from "node:buffer";
|
import { Buffer } from "node:buffer";
|
||||||
import { notImplemented } from "ext:deno_node/_utils.ts";
|
import { notImplemented } from "ext:deno_node/_utils.ts";
|
||||||
import { HandleWrap } from "ext:deno_node/internal_binding/handle_wrap.ts";
|
import { HandleWrap } from "ext:deno_node/internal_binding/handle_wrap.ts";
|
||||||
|
import { ownerSymbol } from "ext:deno_node/internal/async_hooks.ts";
|
||||||
import {
|
import {
|
||||||
AsyncWrap,
|
AsyncWrap,
|
||||||
providerType,
|
providerType,
|
||||||
|
@ -343,7 +344,8 @@ export class LibuvStreamWrap extends HandleWrap {
|
||||||
) {
|
) {
|
||||||
nread = codeMap.get("ECONNRESET")!;
|
nread = codeMap.get("ECONNRESET")!;
|
||||||
} else {
|
} else {
|
||||||
nread = codeMap.get("UNKNOWN")!;
|
this[ownerSymbol].destroy(e);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,16 @@
|
||||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
import { assertEquals, assertInstanceOf } from "@std/assert";
|
import {
|
||||||
|
assertEquals,
|
||||||
|
assertInstanceOf,
|
||||||
|
assertStringIncludes,
|
||||||
|
} from "@std/assert";
|
||||||
import { delay } from "@std/async/delay";
|
import { delay } from "@std/async/delay";
|
||||||
import { fromFileUrl, join } from "@std/path";
|
import { fromFileUrl, join } from "@std/path";
|
||||||
import * as tls from "node:tls";
|
import * as tls from "node:tls";
|
||||||
import * as net from "node:net";
|
import * as net from "node:net";
|
||||||
import * as stream from "node:stream";
|
import * as stream from "node:stream";
|
||||||
|
import { execCode } from "../unit/test_util.ts";
|
||||||
|
|
||||||
const tlsTestdataDir = fromFileUrl(
|
const tlsTestdataDir = fromFileUrl(
|
||||||
new URL("../testdata/tls", import.meta.url),
|
new URL("../testdata/tls", import.meta.url),
|
||||||
|
@ -189,3 +194,24 @@ Deno.test("tlssocket._handle._parentWrap is set", () => {
|
||||||
._parentWrap;
|
._parentWrap;
|
||||||
assertInstanceOf(parentWrap, stream.PassThrough);
|
assertInstanceOf(parentWrap, stream.PassThrough);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Deno.test("tls.connect() throws InvalidData when there's error in certificate", async () => {
|
||||||
|
// Uses execCode to avoid `--unsafely-ignore-certificate-errors` option applied
|
||||||
|
const [status, output] = await execCode(`
|
||||||
|
import tls from "node:tls";
|
||||||
|
const conn = tls.connect({
|
||||||
|
host: "localhost",
|
||||||
|
port: 4557,
|
||||||
|
});
|
||||||
|
|
||||||
|
conn.on("error", (err) => {
|
||||||
|
console.log(err);
|
||||||
|
});
|
||||||
|
`);
|
||||||
|
|
||||||
|
assertEquals(status, 0);
|
||||||
|
assertStringIncludes(
|
||||||
|
output,
|
||||||
|
"InvalidData: invalid peer certificate: UnknownIssuer",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in a new issue