Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/storage-azure-blob/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pegma/storage-azure-blob",
"version": "0.1.1",
"version": "0.1.2",
"description": "Azure Blob Storage adapter for @pegma/storage-blobs.",
"license": "MIT",
"type": "module",
Expand Down Expand Up @@ -30,7 +30,7 @@
},
"dependencies": {
"@azure/storage-blob": "^12.29.1",
"@pegma/storage-blobs": "0.1.1"
"@pegma/storage-blobs": "0.1.2"
},
"scripts": {
"build": "tsc -p tsconfig.json",
Expand Down
32 changes: 31 additions & 1 deletion packages/storage-azure-blob/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
dualStoreConformanceCases,
sizeLimitConformanceCases,
} from "@pegma/storage-blobs/conformance";
import { describe, it } from "vitest";
import { describe, expect, it } from "vitest";

import { BLOB_PORT } from "../../../test/azurite.js";
import { createAzureBlobStore } from "./index.js";
Expand Down Expand Up @@ -91,4 +91,34 @@ describe("createAzureBlobStore", () => {
);
});
}

// Real client against Azurite; only the first createIfNotExists call is
// forced to fail, since the emulator cannot inject a one-shot fault itself.
it("retries container creation after a failed first attempt", async () => {
const container = serviceClient().getContainerClient(nextContainerName());
let createAttempts = 0;
const realCreate = container.createIfNotExists.bind(container);
container.createIfNotExists = async (createOptions) => {
createAttempts += 1;
if (createAttempts === 1) {
throw new Error("transient container create failure");
}
return realCreate(createOptions);
};

const store = createAzureBlobStore({
containerClient: container,
createContainerIfMissing: true,
});

await expect(store.head("some-key")).rejects.toThrow(
"transient container create failure",
);
await expect(store.head("some-key")).resolves.toBeNull();
expect(createAttempts).toBe(2);

// Success stays memoized: further operations do not re-create.
await expect(store.head("some-key")).resolves.toBeNull();
expect(createAttempts).toBe(2);
});
});
10 changes: 9 additions & 1 deletion packages/storage-azure-blob/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,15 @@ export function createAzureBlobStore(
return;
}
if (ensureContainer === undefined) {
ensureContainer = container.createIfNotExists().then(() => undefined);
// Memoize only success: a cached rejection would replay the original
// failure on every operation for the lifetime of the store.
ensureContainer = container.createIfNotExists().then(
() => undefined,
(error: unknown) => {
ensureContainer = undefined;
throw error;
},
);
}
await ensureContainer;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/storage-blobs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pegma/storage-blobs",
"version": "0.1.1",
"version": "0.1.2",
"description": "Provider-neutral object (blob) storage: opaque keys, streaming put/get, conditionals, and a conformance suite.",
"license": "MIT",
"type": "module",
Expand Down
4 changes: 2 additions & 2 deletions packages/storage-cloudflare-r2/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pegma/storage-cloudflare-r2",
"version": "0.1.1",
"version": "0.1.2",
"description": "Cloudflare R2 adapter for @pegma/storage-blobs (S3-compatible API).",
"license": "MIT",
"type": "module",
Expand Down Expand Up @@ -30,7 +30,7 @@
},
"dependencies": {
"@aws-sdk/client-s3": "^3.1097.0",
"@pegma/storage-blobs": "0.1.1"
"@pegma/storage-blobs": "0.1.2"
},
"scripts": {
"build": "tsc -p tsconfig.json",
Expand Down
4 changes: 2 additions & 2 deletions packages/storage-s3/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pegma/storage-s3",
"version": "0.1.1",
"version": "0.1.2",
"description": "AWS S3 / S3-compatible adapter for @pegma/storage-blobs.",
"license": "MIT",
"type": "module",
Expand Down Expand Up @@ -30,7 +30,7 @@
},
"dependencies": {
"@aws-sdk/client-s3": "^3.1097.0",
"@pegma/storage-blobs": "0.1.1"
"@pegma/storage-blobs": "0.1.2"
},
"scripts": {
"build": "tsc -p tsconfig.json",
Expand Down
Loading