Skip to content

Commit 5d6c86e

Browse files
authored
fix(node-server-sdk-dynamodb): remove unnecessary ioredis package (#1306)
This PR removes the unused ioredis dependency from dynamodb storage module. Additionally, I removed some unnecessary non-null assertions. <!-- devin-review-badge-begin --> --- <a href="https://app.devin.ai/review/launchdarkly/js-core/pull/1306" target="_blank"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-open-in-devin-review-dark.svg?v=1"> <img src="https://static.devin.ai/assets/gh-open-in-devin-review-light.svg?v=1" alt="Open in Devin Review"> </picture> </a> <!-- devin-review-badge-end --> <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Low risk: removes an unused dependency and makes small, behavior-preserving TypeScript safety tweaks; only functional change is avoiding in-place mutation in `batchWrite` batching logic. > > **Overview** > Removes the unused `ioredis` dependency from `@launchdarkly/node-server-sdk-dynamodb`. > > Cleans up several unnecessary non-null assertions in DynamoDB store code and updates `DynamoDBClientState.batchWrite` to build 25-item batches via `slice` (no longer mutating the input array). > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit c6542c8. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 0ba743a commit 5d6c86e

4 files changed

Lines changed: 5 additions & 8 deletions

File tree

packages/store/node-server-sdk-dynamodb/package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@
2626
"lint": "npx eslint . --ext .ts",
2727
"lint:fix": "yarn run lint --fix"
2828
},
29-
"dependencies": {
30-
"ioredis": "^5.3.2"
31-
},
3229
"peerDependencies": {
3330
"@aws-sdk/client-dynamodb": "^3.53.0",
3431
"@launchdarkly/node-server-sdk": ">=9.4.3"

packages/store/node-server-sdk-dynamodb/src/DynamoDBBigSegmentStore.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export default class DynamoDBBigSegmentStore implements interfaces.BigSegmentSto
5656
if (data) {
5757
const attr = data[ATTR_SYNC_ON];
5858
if (attr && attr.N) {
59-
return { lastUpToDate: parseInt(attr.N!, 10) };
59+
return { lastUpToDate: parseInt(attr.N, 10) };
6060
}
6161
}
6262
return {};

packages/store/node-server-sdk-dynamodb/src/DynamoDBClientState.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export default class DynamoDBClientState {
3737
private _owned: boolean;
3838

3939
constructor(options?: LDDynamoDBOptions) {
40-
this._prefix = options?.prefix ? `${options!.prefix}:` : DEFAULT_PREFIX;
40+
this._prefix = options?.prefix ? `${options.prefix}:` : DEFAULT_PREFIX;
4141

4242
// We track if we own the client so that we can destroy clients that we own.
4343
if (options?.dynamoDBClient) {
@@ -75,8 +75,8 @@ export default class DynamoDBClientState {
7575
async batchWrite(table: string, params: WriteRequest[]) {
7676
const batches: WriteRequest[][] = [];
7777
// Split into batches of at most 25 commands.
78-
while (params.length) {
79-
batches.push(params.splice(0, WRITE_BATCH_SIZE));
78+
for (let i = 0; i < params.length; i += WRITE_BATCH_SIZE) {
79+
batches.push(params.slice(i, i + WRITE_BATCH_SIZE));
8080
}
8181

8282
// Execute all the batches and wait for them to complete.

packages/store/node-server-sdk-dynamodb/src/TtlFromOptions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ export default function TtlFromOptions(options?: LDDynamoDBOptions): number {
1717
if (options?.cacheTTL === undefined || options.cacheTTL === null) {
1818
return DEFAULT_CACHE_TTL_S;
1919
}
20-
return options!.cacheTTL;
20+
return options.cacheTTL;
2121
}

0 commit comments

Comments
 (0)