Skip to content

Commit f27fd72

Browse files
authored
redis - chore: upgrading @faker-js/faker to 10.2.0 (#1803)
* redis - chore: upgrading @faker-js/faker to 10.2.0 * Update index.ts * Update test.ts
1 parent b4cd729 commit f27fd72

3 files changed

Lines changed: 46 additions & 2 deletions

File tree

packages/dynamo/src/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,16 @@ export class KeyvDynamo extends EventEmitter implements KeyvStoreAdapter {
175175

176176
public async ensureTable(tableName: string): Promise<void> {
177177
try {
178-
await this.client.send(
178+
const response = await this.client.send(
179179
new DescribeTableCommand({ TableName: tableName }),
180180
);
181+
// Table exists but may be in CREATING status - wait if needed
182+
if (response.Table?.TableStatus !== "ACTIVE") {
183+
await waitUntilTableExists(
184+
{ client: this.client, maxWaitTime: 60 },
185+
{ TableName: tableName },
186+
);
187+
}
181188
} catch (error) {
182189
if (error instanceof ResourceNotFoundException) {
183190
await this.createTable(tableName);

packages/dynamo/test/test.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,43 @@ test.it(
157157
},
158158
);
159159

160+
test.it("should wait for table when it exists but is not ACTIVE", async (t) => {
161+
const tableName = randomUUID();
162+
163+
// First create a store and table
164+
const store = new KeyvDynamo({
165+
endpoint: dynamoURL,
166+
tableName,
167+
});
168+
await store.set("test:key1", "value1");
169+
170+
// Now test ensureTable directly with a mocked CREATING status
171+
let describeCallCount = 0;
172+
const originalSend = (store as any).client.send;
173+
(store as any).client.send = test.vi
174+
.fn()
175+
.mockImplementation(async (command) => {
176+
if (command.constructor.name === "DescribeTableCommand") {
177+
describeCallCount++;
178+
if (describeCallCount === 1) {
179+
// First call returns CREATING status
180+
return {
181+
Table: {
182+
TableName: tableName,
183+
TableStatus: "CREATING",
184+
},
185+
};
186+
}
187+
}
188+
return originalSend.call((store as any).client, command);
189+
});
190+
191+
// Call ensureTable directly - this should hit the CREATING branch
192+
await store.ensureTable(tableName);
193+
t.expect(describeCallCount).toBeGreaterThanOrEqual(1);
194+
(store as any).client.send = originalSend;
195+
});
196+
160197
test.it("should verify exposed client property", async (t) => {
161198
const store = new KeyvDynamo({ endpoint: dynamoURL });
162199
t.expect(store.client).toBeDefined();

packages/redis/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
},
5959
"devDependencies": {
6060
"@biomejs/biome": "^2.3.11",
61-
"@faker-js/faker": "^10.1.0",
61+
"@faker-js/faker": "^10.2.0",
6262
"@keyv/test-suite": "workspace:^",
6363
"@vitest/coverage-v8": "^4.0.16",
6464
"rimraf": "^6.1.2",

0 commit comments

Comments
 (0)