Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit eb9778d

Browse files
committed
Normalise Durable Object alarm configuration keys
API: `durableObjectAlarms` -> `durableObjectsAlarms` `wrangler.toml`: `do_alarms` -> `durable_objects_alarms`
1 parent 065e03b commit eb9778d

File tree

4 files changed

+20
-15
lines changed

4 files changed

+20
-15
lines changed

packages/durable-objects/src/plugin.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export type DurableObjectsObjectsOptions = Record<
3333
export interface DurableObjectsOptions {
3434
durableObjects?: DurableObjectsObjectsOptions;
3535
durableObjectsPersist?: boolean | string;
36-
durableObjectAlarms?: boolean;
36+
durableObjectsAlarms?: boolean;
3737
}
3838

3939
interface ProcessedDurableObject {
@@ -93,9 +93,9 @@ export class DurableObjectsPlugin
9393
description: "Enable Durable Object alarms (enabled by default)",
9494
negatable: true,
9595
logName: "Durable Object Alarms",
96-
fromWrangler: ({ miniflare }) => miniflare?.do_alarms,
96+
fromWrangler: ({ miniflare }) => miniflare?.durable_objects_alarms,
9797
})
98-
durableObjectAlarms?: boolean;
98+
durableObjectsAlarms?: boolean;
9999

100100
readonly #persist?: boolean | string;
101101

@@ -199,7 +199,7 @@ export class DurableObjectsPlugin
199199
}
200200

201201
async #setupAlarms(storage: StorageFactory): Promise<void> {
202-
if (this.durableObjectAlarms === false) return;
202+
if (this.durableObjectsAlarms === false) return;
203203
// if the alarm store doesn't exist yet, create
204204
await this.#alarmStore.setupStore(storage, this.#persist);
205205
await this.#alarmStore.setupAlarms(async (objectKey: string) => {

packages/durable-objects/test/namespace.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,13 @@ test("DurableObjectState: kAlarm: no alarm method; setAlarm throws while getAlar
160160
});
161161

162162
class TestObject implements DurableObject {
163-
constructor(private readonly state: DurableObjectState) {}
163+
constructor(private readonly _state: DurableObjectState) {}
164164

165165
fetch(): Response {
166166
return new Response();
167167
}
168168
}
169-
plugin.setup(factory);
169+
await plugin.setup(factory);
170170
plugin.beforeReload();
171171
plugin.reload({}, { TestObject }, new Map());
172172

@@ -246,7 +246,7 @@ test("DurableObjectStub: fetch: throws with relative urls if compatibility flag
246246
const factory = new MemoryStorageFactory();
247247
const plugin = new DurableObjectsPlugin(
248248
{ log, compat, rootPath },
249-
{ durableObjects: { TEST: "TestObject" }, durableObjectAlarms: true }
249+
{ durableObjects: { TEST: "TestObject" }, durableObjectsAlarms: true }
250250
);
251251
plugin.beforeReload();
252252
plugin.reload({}, { TestObject }, new Map());
@@ -267,7 +267,7 @@ test("DurableObjectStub: fetch: throws with unknown protocols if compatibility f
267267
const factory = new MemoryStorageFactory();
268268
const plugin = new DurableObjectsPlugin(
269269
{ log, compat, rootPath },
270-
{ durableObjects: { TEST: "TestObject" }, durableObjectAlarms: true }
270+
{ durableObjects: { TEST: "TestObject" }, durableObjectsAlarms: true }
271271
);
272272
plugin.beforeReload();
273273
plugin.reload({}, { TestObject }, new Map());
@@ -290,7 +290,7 @@ test("DurableObjectStub: fetch: logs warning with unknown protocol if compatibil
290290
const factory = new MemoryStorageFactory();
291291
const plugin = new DurableObjectsPlugin(
292292
{ log, compat, rootPath },
293-
{ durableObjects: { TEST: "TestObject" }, durableObjectAlarms: true }
293+
{ durableObjects: { TEST: "TestObject" }, durableObjectsAlarms: true }
294294
);
295295
plugin.beforeReload();
296296
plugin.reload({}, { TestObject }, new Map());

packages/durable-objects/test/plugin.spec.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,15 @@ test("DurableObjectsPlugin: parses options from argv", (t) => {
3737
"OBJECT2=Object2@api",
3838
"--do-persist",
3939
"path",
40+
"--no-do-alarms",
4041
]);
4142
t.deepEqual(options, {
4243
durableObjects: {
4344
OBJECT1: "Object1",
4445
OBJECT2: { className: "Object2", scriptName: "api" },
4546
},
4647
durableObjectsPersist: "path",
48+
durableObjectsAlarms: false,
4749
});
4850
options = parsePluginArgv(DurableObjectsPlugin, [
4951
"-o",
@@ -68,22 +70,25 @@ test("DurableObjectsPlugin: parses options from wrangler config", (t) => {
6870
{ name: "OBJECT2", class_name: "Object2", script_name: "other_script" },
6971
],
7072
},
71-
miniflare: { durable_objects_persist: "path" },
73+
miniflare: {
74+
durable_objects_persist: "path",
75+
durable_objects_alarms: false,
76+
},
7277
});
7378
t.deepEqual(options, {
7479
durableObjects: {
7580
OBJECT1: { className: "Object1", scriptName: undefined },
7681
OBJECT2: { className: "Object2", scriptName: "other_script" },
7782
},
7883
durableObjectsPersist: "path",
79-
durableObjectAlarms: undefined,
84+
durableObjectsAlarms: false,
8085
});
8186
});
8287
test("DurableObjectsPlugin: logs options", (t) => {
8388
const logs = logPluginOptions(DurableObjectsPlugin, {
8489
durableObjects: { OBJECT1: "Object1", OBJECT2: "Object2" },
8590
durableObjectsPersist: true,
86-
durableObjectAlarms: true,
91+
durableObjectsAlarms: true,
8792
});
8893
t.deepEqual(logs, [
8994
"Durable Objects: OBJECT1, OBJECT2",
@@ -297,9 +302,9 @@ test("DurableObjectsPlugin: setup alarms and dispose alarms", async (t) => {
297302
const factory = new MemoryStorageFactory();
298303
const plugin = new DurableObjectsPlugin(ctx, {
299304
durableObjects: { TEST: "TestObject" },
300-
durableObjectAlarms: false,
305+
durableObjectsAlarms: false,
301306
});
302307
plugin.setup(factory);
303308
plugin.dispose();
304-
t.false(plugin.durableObjectAlarms);
309+
t.false(plugin.durableObjectsAlarms);
305310
});

packages/shared/src/wrangler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export interface WranglerEnvironmentConfig {
5151
cache?: boolean;
5252
cache_persist?: boolean | string;
5353
durable_objects_persist?: boolean | string;
54-
do_alarms?: boolean;
54+
durable_objects_alarms?: boolean;
5555
env_path?: string;
5656
host?: string;
5757
port?: number;

0 commit comments

Comments
 (0)