Skip to content

Commit 9205440

Browse files
committed
socket: more portable exec()
webpack was doing the error-catching before.
1 parent dbaf756 commit 9205440

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

packages/socket/src/reconnectingsocket.spec.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ import { ReconnectingSocket } from "./reconnectingsocket";
33
/** @see https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback */
44
type Exec = (command: string, callback: (error: null | (Error & { readonly code?: number })) => void) => void;
55

6-
const getExec = async (): Promise<Exec | undefined> => (await import("child_process")).exec;
6+
const getExec = async (): Promise<Exec | undefined> => {
7+
try {
8+
return (await import("child_process")).exec;
9+
} catch {
10+
return undefined;
11+
}
12+
};
713

814
function pendingWithoutSocketServer(): void {
915
if (typeof process !== "undefined" && process?.env.SOCKETSERVER_ENABLED) {

0 commit comments

Comments
 (0)