diff --git a/jsconfig.json b/jsconfig.json index 5816065..9253e24 100644 --- a/jsconfig.json +++ b/jsconfig.json @@ -1,12 +1,13 @@ { "compilerOptions": { - "target": "ES6", - "module": "commonjs" + "target": "ES6", + "module": "commonjs" }, "exclude": [ - "node_modules", - "**/node_modules/*", - "coverage", - "doc" + "node_modules", + "**/node_modules/*", + "coverage", + "doc", + "examples/ignored/*" ] -} \ No newline at end of file +} diff --git a/package-lock.json b/package-lock.json index 907c768..db075f5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "3.10.29", "license": "MIT", "dependencies": { - "axios": "^1.6.6", + "axios": "^1.7.9", "isomorphic-ws": "^4.0.1", "ws": "^7.4.0" }, @@ -2294,9 +2294,10 @@ "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" }, "node_modules/axios": { - "version": "1.7.7", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.7.tgz", - "integrity": "sha512-S4kL7XrjgBmvdGut0sN3yJxqYzrDOnivkBiN0OFs6hLiUam3UPvswUo0kqGyhqUZGEOytHyumEdXsAkgCOUf3Q==", + "version": "1.7.9", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.9.tgz", + "integrity": "sha512-LhLcE7Hbiryz8oMDdDptSrWowmB4Bl6RCt6sIJKpRB4XtVf0iEgewX3au/pJqm+Py1kCASkb/FFKjxQaLtxJvw==", + "license": "MIT", "dependencies": { "follow-redirects": "^1.15.6", "form-data": "^4.0.0", @@ -8784,9 +8785,9 @@ "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" }, "axios": { - "version": "1.7.7", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.7.tgz", - "integrity": "sha512-S4kL7XrjgBmvdGut0sN3yJxqYzrDOnivkBiN0OFs6hLiUam3UPvswUo0kqGyhqUZGEOytHyumEdXsAkgCOUf3Q==", + "version": "1.7.9", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.9.tgz", + "integrity": "sha512-LhLcE7Hbiryz8oMDdDptSrWowmB4Bl6RCt6sIJKpRB4XtVf0iEgewX3au/pJqm+Py1kCASkb/FFKjxQaLtxJvw==", "requires": { "follow-redirects": "^1.15.6", "form-data": "^4.0.0", diff --git a/package.json b/package.json index 4a495d3..6318778 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "Stefan Aebischer (https://pixtron.ch)" ], "dependencies": { - "axios": "^1.6.6", + "axios": "^1.7.9", "isomorphic-ws": "^4.0.1", "ws": "^7.4.0" }, diff --git a/src/util/BaseWSClient.ts b/src/util/BaseWSClient.ts index 38c7c52..cccf766 100644 --- a/src/util/BaseWSClient.ts +++ b/src/util/BaseWSClient.ts @@ -132,13 +132,14 @@ export abstract class BaseWebsocketClient< private timeOffsetMs: number = 0; - private pendingTopicSubscriptionRequests: { - [key in TWSKey]?: { - [requestKey: string]: - | undefined - | WsKeyPendingTopicSubscriptions; - }; - } = {}; + /** + * A nested wsKey->request key store. + * pendingTopicSubscriptionRequests[wsKey][requestKey] = WsKeyPendingTopicSubscriptions + */ + private pendingTopicSubscriptionRequests: Record< + string, + Record> + > = {}; constructor( options?: WSClientConfigurableOptions, @@ -281,9 +282,9 @@ export abstract class BaseWebsocketClient< const requestKey = requestData.requestKey; // Should not be possible to see a requestKey collision in the current design, since the req ID increments automatically with every request, so this should never be true, but just in case a future mistake happens... - const existingWsKeyPendingRequests = - this.getWsKeyPendingSubscriptionStore(wsKey); - if (existingWsKeyPendingRequests[requestKey]) { + + const pendingSubReqs = this.getWsKeyPendingSubscriptionStore(wsKey); + if (pendingSubReqs[requestKey]) { throw new Error( 'Implementation error: attempted to upsert pending topics with duplicate request ID!', ); @@ -294,8 +295,8 @@ export abstract class BaseWebsocketClient< resolver: TopicsPendingSubscriptionsResolver, rejector: TopicsPendingSubscriptionsRejector, ) => { - const store = this.getWsKeyPendingSubscriptionStore(wsKey); - store[requestKey] = { + const pendingSubReqs = this.getWsKeyPendingSubscriptionStore(wsKey); + pendingSubReqs[requestKey] = { requestData: requestData.requestEvent, resolver, rejector, @@ -305,8 +306,8 @@ export abstract class BaseWebsocketClient< } protected removeTopicPendingSubscription(wsKey: TWSKey, requestKey: string) { - const store = this.getWsKeyPendingSubscriptionStore(wsKey); - delete store[requestKey]; + const pendingSubReqs = this.getWsKeyPendingSubscriptionStore(wsKey); + delete pendingSubReqs[requestKey]; } private clearTopicsPendingSubscriptions( @@ -315,9 +316,10 @@ export abstract class BaseWebsocketClient< rejectReason: string, ) { if (rejectAll) { - const wsKeyPendingRequests = this.getWsKeyPendingSubscriptionStore(wsKey); - for (const requestKey in wsKeyPendingRequests) { - const request = wsKeyPendingRequests[requestKey]; + const pendingSubReqs = this.getWsKeyPendingSubscriptionStore(wsKey); + + for (const requestKey in pendingSubReqs) { + const request = pendingSubReqs[requestKey]; request?.rejector(request.requestData, rejectReason); } }