Skip to content

Commit

Permalink
fix(ext/node): add autoSelectFamily option to net.createConnection
Browse files Browse the repository at this point in the history
  • Loading branch information
kt3k committed Oct 31, 2024
1 parent 51978a7 commit d3d005b
Show file tree
Hide file tree
Showing 7 changed files with 777 additions and 12 deletions.
26 changes: 25 additions & 1 deletion ext/node/polyfills/internal/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import { primordials } from "ext:core/mod.js";
const { JSONStringify, SymbolFor } = primordials;
const { JSONStringify, SafeArrayIterator, SymbolFor } = primordials;
import { format, inspect } from "ext:deno_node/internal/util/inspect.mjs";
import { codes } from "ext:deno_node/internal/error_codes.ts";
import {
Expand Down Expand Up @@ -1874,6 +1874,11 @@ export class ERR_SOCKET_CLOSED extends NodeError {
super("ERR_SOCKET_CLOSED", `Socket is closed`);
}
}
export class ERR_SOCKET_CONNECTION_TIMEOUT extends NodeError {
constructor() {
super("ERR_SOCKET_CONNECTION_TIMEOUT", `Socket connection timeout`);
}
}
export class ERR_SOCKET_DGRAM_IS_CONNECTED extends NodeError {
constructor() {
super("ERR_SOCKET_DGRAM_IS_CONNECTED", `Already connected`);
Expand Down Expand Up @@ -2646,11 +2651,30 @@ export function aggregateTwoErrors(
}
return innerError || outerError;
}

export class NodeAggregateError extends AggregateError {
code: string;
constructor(errors, message) {
super(new SafeArrayIterator(errors), message);
this.code = errors[0]?.code;
}

get [kIsNodeError]() {
return true;
}

// deno-lint-ignore adjacent-overload-signatures
get ["constructor"]() {
return AggregateError;
}
}

codes.ERR_IPC_CHANNEL_CLOSED = ERR_IPC_CHANNEL_CLOSED;
codes.ERR_INVALID_ARG_TYPE = ERR_INVALID_ARG_TYPE;
codes.ERR_INVALID_ARG_VALUE = ERR_INVALID_ARG_VALUE;
codes.ERR_OUT_OF_RANGE = ERR_OUT_OF_RANGE;
codes.ERR_SOCKET_BAD_PORT = ERR_SOCKET_BAD_PORT;
codes.ERR_SOCKET_CONNECTION_TIMEOUT = ERR_SOCKET_CONNECTION_TIMEOUT;
codes.ERR_BUFFER_OUT_OF_BOUNDS = ERR_BUFFER_OUT_OF_BOUNDS;
codes.ERR_UNKNOWN_ENCODING = ERR_UNKNOWN_ENCODING;
codes.ERR_PARSE_ARGS_INVALID_OPTION_VALUE = ERR_PARSE_ARGS_INVALID_OPTION_VALUE;
Expand Down
1 change: 1 addition & 0 deletions ext/node/polyfills/internal/net.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,5 @@ export function makeSyncWrite(fd: number) {
};
}

export const kReinitializeHandle = Symbol("kReinitializeHandle");
export const normalizedArgsSymbol = Symbol("normalizedArgs");
2 changes: 2 additions & 0 deletions ext/node/polyfills/internal_binding/uv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -530,10 +530,12 @@ export function mapSysErrnoToUvErrno(sysErrno: number): number {

export const UV_EAI_MEMORY = codeMap.get("EAI_MEMORY")!;
export const UV_EBADF = codeMap.get("EBADF")!;
export const UV_ECANCELED = codeMap.get("ECANCELED")!;
export const UV_EEXIST = codeMap.get("EEXIST");
export const UV_EINVAL = codeMap.get("EINVAL")!;
export const UV_ENOENT = codeMap.get("ENOENT");
export const UV_ENOTSOCK = codeMap.get("ENOTSOCK")!;
export const UV_ETIMEDOUT = codeMap.get("ETIMEDOUT")!;
export const UV_UNKNOWN = codeMap.get("UNKNOWN")!;

export function errname(errno: number): string {
Expand Down
Loading

0 comments on commit d3d005b

Please sign in to comment.