mirror of
https://github.com/logos-messaging/js-waku.git
synced 2026-01-02 13:53:12 +00:00
fix access to process variable (#2201)
This commit is contained in:
parent
ef78e52c45
commit
b5d2c013a1
@ -17,6 +17,7 @@ import {
|
||||
import { derivePubsubTopicsFromNetworkConfig, Logger } from "@waku/utils";
|
||||
import { createLibp2p } from "libp2p";
|
||||
|
||||
import { isTestEnvironment } from "../env.js";
|
||||
import {
|
||||
CreateWakuNodeOptions,
|
||||
DefaultPingMaxInboundStreams,
|
||||
@ -36,7 +37,7 @@ export async function defaultLibp2p(
|
||||
options?: Partial<CreateLibp2pOptions>,
|
||||
userAgent?: string
|
||||
): Promise<Libp2p> {
|
||||
if (!options?.hideWebSocketInfo && process?.env?.NODE_ENV !== "test") {
|
||||
if (!options?.hideWebSocketInfo && !isTestEnvironment()) {
|
||||
/* eslint-disable no-console */
|
||||
console.info(
|
||||
"%cIgnore WebSocket connection failures",
|
||||
@ -54,7 +55,7 @@ export async function defaultLibp2p(
|
||||
: {};
|
||||
|
||||
const filter =
|
||||
options?.filterMultiaddrs === false || process?.env?.NODE_ENV === "test"
|
||||
options?.filterMultiaddrs === false || isTestEnvironment()
|
||||
? filterAll
|
||||
: wss;
|
||||
|
||||
|
||||
8
packages/sdk/src/env.ts
Normal file
8
packages/sdk/src/env.ts
Normal file
@ -0,0 +1,8 @@
|
||||
export function isTestEnvironment(): boolean {
|
||||
try {
|
||||
return process?.env?.NODE_ENV === "test";
|
||||
} catch (_e) {
|
||||
// process variable is not defined in PROD environment
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user