Skip to content

Commit d5f467a

Browse files
committed
review fix
1 parent c37eb82 commit d5f467a

File tree

3 files changed

+16
-17
lines changed

3 files changed

+16
-17
lines changed

packages/cloudflare/src/api/durable-objects/queue.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,10 @@ describe("DurableObjectQueue", () => {
208208

209209
it("should add an alarm if there are failed states", async () => {
210210
const queue = createDurableObjectQueue({ fetchDuration: 10 });
211-
const nextAlarm = Date.now() + 1000;
212-
queue.routeInFailedState.set("id", { msg: createMessage("id"), retryCount: 0, nextAlarmMs: nextAlarm });
211+
const nextAlarmMs = Date.now() + 1000;
212+
queue.routeInFailedState.set("id", { msg: createMessage("id"), retryCount: 0, nextAlarmMs });
213213
await queue.addAlarm();
214-
expect(getStorage(queue).setAlarm).toHaveBeenCalledWith(nextAlarm);
214+
expect(getStorage(queue).setAlarm).toHaveBeenCalledWith(nextAlarmMs);
215215
});
216216

217217
it("should not add an alarm if there is already an alarm set", async () => {
@@ -225,9 +225,9 @@ describe("DurableObjectQueue", () => {
225225

226226
it("should set the alarm to the lowest nextAlarm", async () => {
227227
const queue = createDurableObjectQueue({ fetchDuration: 10 });
228-
const nextAlarm = Date.now() + 1000;
228+
const nextAlarmMs = Date.now() + 1000;
229229
const firstAlarm = Date.now() + 500;
230-
queue.routeInFailedState.set("id", { msg: createMessage("id"), retryCount: 0, nextAlarmMs: nextAlarm });
230+
queue.routeInFailedState.set("id", { msg: createMessage("id"), retryCount: 0, nextAlarmMs });
231231
queue.routeInFailedState.set("id2", {
232232
msg: createMessage("id2"),
233233
retryCount: 0,

packages/cloudflare/src/api/durable-objects/queue.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -272,17 +272,17 @@ export class DurableObjectQueueHandler extends DurableObject<CloudflareEnv> {
272272
*/
273273
checkSyncTable(msg: QueueMessage) {
274274
try {
275-
const isNewer = this.sql
275+
const numNewer = this.sql
276276
.exec<{
277-
isNewer: number;
277+
numNewer: number;
278278
}>(
279-
"SELECT COUNT(*) as isNewer FROM sync WHERE id = ? AND lastSuccess > ?",
279+
"SELECT COUNT(*) as numNewer FROM sync WHERE id = ? AND lastSuccess > ? LIMIT 1",
280280
`${msg.MessageBody.host}${msg.MessageBody.url}`,
281281
Math.round(msg.MessageBody.lastModified / 1000)
282282
)
283-
.one().isNewer;
283+
.one().numNewer;
284284

285-
return isNewer > 0;
285+
return numNewer > 0;
286286
// eslint-disable-next-line @typescript-eslint/no-unused-vars
287287
} catch (e: unknown) {
288288
return false;

packages/cloudflare/src/cli/build/open-next/compileDurableObjects.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import fs from "node:fs";
21
import { createRequire } from "node:module";
32
import path from "node:path";
43

4+
import { loadBuildId, loadPrerenderManifest } from "@opennextjs/aws/adapters/config/util.js";
55
import { type BuildOptions, esbuildSync, getPackagePath } from "@opennextjs/aws/build/helper.js";
66

77
export function compileDurableObjects(buildOpts: BuildOptions) {
@@ -17,13 +17,12 @@ export function compileDurableObjects(buildOpts: BuildOptions) {
1717
".next"
1818
);
1919

20-
// TODO: Reuse the manifest
21-
const prerenderManifest = path.join(baseManifestPath, "prerender-manifest.json");
22-
const prerenderManifestContent = fs.readFileSync(prerenderManifest, "utf-8");
23-
const prerenderManifestJson = JSON.parse(prerenderManifestContent);
24-
const previewModeId = prerenderManifestJson.preview.previewModeId;
20+
// We need to change the type in aws
21+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
22+
const prerenderManifest = loadPrerenderManifest(baseManifestPath) as any;
23+
const previewModeId = prerenderManifest.preview.previewModeId;
2524

26-
const BUILD_ID = fs.readFileSync(path.join(baseManifestPath, "BUILD_ID"), "utf-8");
25+
const BUILD_ID = loadBuildId(baseManifestPath);
2726

2827
return esbuildSync(
2928
{

0 commit comments

Comments
 (0)