Skip to content

Commit 2ee38a0

Browse files
authored
fix: improve upload error handling (#28)
1 parent 7faa962 commit 2ee38a0

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/util.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ export async function uploadSource(
7474
zipPath: string,
7575
): Promise<string> {
7676
const zipFile = fs.createReadStream(zipPath);
77-
const client = new Gaxios();
78-
client.request({
77+
const client = new Gaxios({ retryConfig: { retry: 5 } });
78+
const resp = await client.request({
7979
method: 'PUT',
8080
body: zipFile,
8181
url: uploadUrl,
@@ -84,5 +84,10 @@ export async function uploadSource(
8484
'x-goog-content-length-range': '0,104857600',
8585
},
8686
});
87+
if (resp.status != 200) {
88+
throw new Error(
89+
`Failed to upload function source code: ${resp.statusText}`,
90+
);
91+
}
8792
return uploadUrl;
8893
}

0 commit comments

Comments
 (0)