Skip to content

Commit 1f2d636

Browse files
committed
refactor: update imports and add notes for Node.js-only functionality in BaseRestClient and webpack config
1 parent 3d9ddf7 commit 1f2d636

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

src/types/websockets/ws-general.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { AxiosRequestConfig } from 'axios';
2-
import { ClientRequestArgs } from 'http';
2+
import type { ClientRequestArgs } from 'http';
33
import WebSocket from 'isomorphic-ws';
44

55
import { RestClientOptions } from '../../util/requestUtils';

src/util/BaseRestClient.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import axios, { AxiosError, AxiosRequestConfig, Method } from 'axios';
2+
// NOTE: https.Agent is Node.js-only and not available in browser environments
3+
// Browser builds (via webpack) exclude this module - see webpack.config.js fallback settings
24
import https from 'https';
35

46
import { BinanceBaseUrlKey } from '../types/shared';
@@ -78,6 +80,9 @@ export default abstract class BaseRestClient {
7880
};
7981

8082
// If enabled, configure a https agent with keepAlive enabled
83+
// NOTE: This is Node.js-only functionality. In browser environments, this code is skipped
84+
// as the 'https' module is excluded via webpack fallback configuration.
85+
// Browser connection pooling is handled automatically by the browser itself.
8186
if (this.options.keepAlive) {
8287
// Extract existing https agent parameters, if provided, to prevent the keepAlive flag from overwriting an existing https agent completely
8388
const existingHttpsAgent = this.globalRequestOptions.httpsAgent as

webpack/webpack.config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ function generateConfig(name) {
2222
path.resolve(__dirname, "../lib/util/browser-support.js"),
2323
},
2424
fallback: {
25-
https: false,
25+
// Node.js core modules not available in browsers
26+
// The REST client's https.Agent (for keepAlive) is Node.js-only and won't work in browsers
27+
"http": false,
28+
"https": false,
2629
}
2730
},
2831
module: {

0 commit comments

Comments
 (0)