Skip to content

Commit 8c3fd52

Browse files
Nit changes
1 parent 8d98ce3 commit 8c3fd52

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/content/docs/workflows/examples/backup-d1.mdx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ tags:
55
- Workflows
66
- D1
77
- R2
8+
languages:
9+
- Typescript
810
pcx_content_type: configuration
911
title: Backup and save D1 database
1012
sidebar:
@@ -73,12 +75,14 @@ export class backupWorkflow extends WorkflowEntrypoint<Env, Params> {
7375
const res = await fetch(url, { method, headers, body: JSON.stringify(payload) });
7476
const { result } = (await res.json()) as any;
7577

76-
// The endpoint sends `signed_url` when the backup is ready.
78+
// The endpoint sends `signed_url` when the backup is ready to download.
7779
// If we don't get `signed_url` we throw to retry the step.
7880
if (!result?.signed_url) throw new Error("Missing `signed_url`");
7981

8082
const dumpResponse = await fetch(result.signed_url);
81-
// We stream the file directly to R2
83+
if (!dumpResponse.ok) throw new Error("Failed to fetch dump file");
84+
85+
// Finally, stream the file directly to R2
8286
await this.env.BACKUP_BUCKET.put(result.filename, dumpResponse.body);
8387
});
8488
}

0 commit comments

Comments
 (0)