Skip to content

Commit

Permalink
[wrangler] log startup time in version upload
Browse files Browse the repository at this point in the history
Same as #6318 , but for
version upload
  • Loading branch information
taylorlee committed Jul 31, 2024
1 parent 9f02173 commit 7c45ea2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/moody-baboons-wonder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wrangler": minor
---

feat: log Worker startup time in the `version upload` command
2 changes: 2 additions & 0 deletions packages/wrangler/e2e/versions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ describe("versions deploy", { timeout: TIMEOUT }, () => {

expect(normalize(upload.stdout)).toMatchInlineSnapshot(`
"Total Upload: xx KiB / gzip: xx KiB
Worker Startup Time: 100 ms
Worker Version ID: 00000000-0000-0000-0000-000000000000
Uploaded tmp-e2e-worker-00000000-0000-0000-0000-000000000000 (TIMINGS)
To deploy this version to production traffic use the command wrangler versions deploy --experimental-versions
Expand Down Expand Up @@ -175,6 +176,7 @@ describe("versions deploy", { timeout: TIMEOUT }, () => {
expect(normalize(upload.stdout)).toMatchInlineSnapshot(`
"Total Upload: xx KiB / gzip: xx KiB
Worker Version ID: 00000000-0000-0000-0000-000000000000
Worker Startup Time: 100 ms
Uploaded tmp-e2e-worker-00000000-0000-0000-0000-000000000000 (TIMINGS)
To deploy this version to production traffic use the command wrangler versions deploy --experimental-versions
Changes to non-versioned settings (config properties 'logpush' or 'tail_consumers') take effect after your next deployment using the command wrangler versions deploy --experimental-versions
Expand Down
13 changes: 12 additions & 1 deletion packages/wrangler/src/versions/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,11 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m

printBindings({ ...withoutStaticAssets, vars: maskedVars });

if (!props.dryRun) {
if (props.dryRun) {
printBindings({ ...withoutStaticAssets, vars: maskedVars });
} else {
await ensureQueuesExistByConfig(config);
let bindingsPrinted = false;

// Upload the script so it has time to propagate.
// We can also now tell whether available_on_subdomain is set
Expand All @@ -431,6 +434,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
pipeline_hash: string | null;
mutable_pipeline_id: string | null;
deployment_id: string | null;
startup_time_ms: number;
}>(
workerUrl,
{
Expand All @@ -446,8 +450,15 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
})
);

logger.log("Worker Startup Time:", result.startup_time_ms, "ms");
bindingsPrinted = true;
printBindings({ ...withoutStaticAssets, vars: maskedVars });
logger.log("Worker Version ID:", result.id);
} catch (err) {
if (!bindingsPrinted) {
printBindings({ ...withoutStaticAssets, vars: maskedVars });
}

helpIfErrorIsSizeOrScriptStartup(err, dependencies);

// Apply source mapping to validation startup errors if possible
Expand Down

0 comments on commit 7c45ea2

Please sign in to comment.