Skip to content

Commit c3e19b7

Browse files
authored
print startup time in version upload (#6392)
* [wrangler] log startup time in version upload Same as #6318 , but for version upload * [wrangler] remove bundle size warning Bundle size was a proxy for startup time. Now that we have startup time reported, focus on bundle size is less relevant. Tracked internally as EW-8219
1 parent 5146775 commit c3e19b7

File tree

8 files changed

+31
-41
lines changed

8 files changed

+31
-41
lines changed

.changeset/moody-baboons-wonder.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"wrangler": minor
3+
---
4+
5+
feat: log Worker startup time in the `version upload` command

.changeset/witty-bats-drum.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"wrangler": patch
3+
---
4+
5+
fix: remove bundle size warning from Worker deploy commands
6+
7+
Bundle size was a proxy for startup time. Now that we have startup time
8+
reported, focus on bundle size is less relevant.

packages/wrangler/e2e/helpers/normalize.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ export function normalizeSlashes(str: string): string {
9898
* Use this in snapshot tests to be resilient to slight changes in timing of processing.
9999
*/
100100
export function stripTimings(stdout: string): string {
101-
return stdout.replace(/\(\d+\.\d+ sec\)/g, "(TIMINGS)");
101+
return stdout
102+
.replace(/\(\d+\.\d+ sec\)/g, "(TIMINGS)")
103+
.replace(/\d+ ms/g, "(TIMINGS)");
102104
}
103105

104106
/**

packages/wrangler/e2e/versions.test.ts

+2
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ describe("versions deploy", { timeout: TIMEOUT }, () => {
6060

6161
expect(normalize(upload.stdout)).toMatchInlineSnapshot(`
6262
"Total Upload: xx KiB / gzip: xx KiB
63+
Worker Startup Time: (TIMINGS)
6364
Worker Version ID: 00000000-0000-0000-0000-000000000000
6465
Uploaded tmp-e2e-worker-00000000-0000-0000-0000-000000000000 (TIMINGS)
6566
To deploy this version to production traffic use the command wrangler versions deploy --experimental-versions
@@ -174,6 +175,7 @@ describe("versions deploy", { timeout: TIMEOUT }, () => {
174175

175176
expect(normalize(upload.stdout)).toMatchInlineSnapshot(`
176177
"Total Upload: xx KiB / gzip: xx KiB
178+
Worker Startup Time: (TIMINGS)
177179
Worker Version ID: 00000000-0000-0000-0000-000000000000
178180
Uploaded tmp-e2e-worker-00000000-0000-0000-0000-000000000000 (TIMINGS)
179181
To deploy this version to production traffic use the command wrangler versions deploy --experimental-versions

packages/wrangler/src/__tests__/deploy.test.ts

+1-31
Original file line numberDiff line numberDiff line change
@@ -9403,35 +9403,7 @@ export default{
94039403
// keeping these as unit tests to try and keep them snappy, as they often deal with
94049404
// big files that would take a while to deal with in a full wrangler test
94059405

9406-
test("should print the bundle size and warn about large scripts when > 1MiB", async () => {
9407-
const bigModule = Buffer.alloc(10_000_000);
9408-
randomFillSync(bigModule);
9409-
await printBundleSize({ name: "index.js", content: "" }, [
9410-
{
9411-
name: "index.js",
9412-
filePath: undefined,
9413-
content: bigModule,
9414-
type: "buffer",
9415-
},
9416-
]);
9417-
9418-
expect(std).toMatchInlineSnapshot(`
9419-
Object {
9420-
"debug": "",
9421-
"err": "",
9422-
"info": "",
9423-
"out": "Total Upload: xx KiB / gzip: xx KiB",
9424-
"warn": "▲ [WARNING] We recommend keeping your script less than 1MiB (1024 KiB) after gzip. Exceeding this can affect cold start time. Consider using Wrangler's \`--minify\` option to reduce your bundle size.
9425-
9426-
",
9427-
}
9428-
`);
9429-
});
9430-
9431-
test("should not warn about bundle sizes when NO_SCRIPT_SIZE_WARNING is set", async () => {
9432-
const previousValue = process.env.NO_SCRIPT_SIZE_WARNING;
9433-
process.env.NO_SCRIPT_SIZE_WARNING = "true";
9434-
9406+
test("should print the bundle size", async () => {
94359407
const bigModule = Buffer.alloc(10_000_000);
94369408
randomFillSync(bigModule);
94379409
await printBundleSize({ name: "index.js", content: "" }, [
@@ -9452,8 +9424,6 @@ export default{
94529424
"warn": "",
94539425
}
94549426
`);
9455-
9456-
process.env.NO_SCRIPT_SIZE_WARNING = previousValue;
94579427
});
94589428

94599429
test("should print the top biggest dependencies in the bundle when upload fails", () => {

packages/wrangler/src/deployment-bundle/bundle-reporter.ts

-6
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,6 @@ export async function printBundleSize(
4040
: chalk.green(bundleReport);
4141

4242
logger.log(`Total Upload: ${colorizedReport}`);
43-
44-
if (gzipSize > ALLOWED_INITIAL_MAX && !process.env.NO_SCRIPT_SIZE_WARNING) {
45-
logger.warn(
46-
"We recommend keeping your script less than 1MiB (1024 KiB) after gzip. Exceeding this can affect cold start time. Consider using Wrangler's `--minify` option to reduce your bundle size."
47-
);
48-
}
4943
}
5044

5145
export function printOffendingDependencies(

packages/wrangler/src/versions/upload.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -416,8 +416,11 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
416416

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

419-
if (!props.dryRun) {
419+
if (props.dryRun) {
420+
printBindings({ ...withoutStaticAssets, vars: maskedVars });
421+
} else {
420422
await ensureQueuesExistByConfig(config);
423+
let bindingsPrinted = false;
421424

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

453+
logger.log("Worker Startup Time:", result.startup_time_ms, "ms");
454+
bindingsPrinted = true;
455+
printBindings({ ...withoutStaticAssets, vars: maskedVars });
449456
logger.log("Worker Version ID:", result.id);
450457
} catch (err) {
458+
if (!bindingsPrinted) {
459+
printBindings({ ...withoutStaticAssets, vars: maskedVars });
460+
}
461+
451462
helpIfErrorIsSizeOrScriptStartup(err, dependencies);
452463

453464
// Apply source mapping to validation startup errors if possible

packages/wrangler/turbo.json

-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
"SPARROW_SOURCE_KEY",
2929
"ALGOLIA_APP_ID",
3030
"ALGOLIA_PUBLIC_KEY",
31-
"NO_SCRIPT_SIZE_WARNING",
3231
"CLOUDFLARE_API_TOKEN",
3332
"CLOUDFLARE_ACCOUNT_ID",
3433
"WRANGLER_AUTH_DOMAIN",
@@ -39,7 +38,6 @@
3938
"CF_PAGES",
4039
"CI",
4140
"CF_PAGES_UPLOAD_JWT",
42-
"NO_SCRIPT_SIZE_WARNING",
4341
"EXPERIMENTAL_MIDDLEWARE",
4442
"NO_D1_WARNING",
4543
"NO_HYPERDRIVE_WARNING",

0 commit comments

Comments
 (0)