Skip to content

Conversation

@alfonso-noriega
Copy link
Contributor

@alfonso-noriega alfonso-noriega commented Oct 31, 2025

WHY are these changes introduced?

The current implementation of buildExtensions processes each extension event individually, which can lead to inefficient handling when multiple events occur for the same extension.

WHAT is this pull request doing?

Optimizes the extension build process by grouping extension events by extension UID before processing them. This ensures that when multiple events occur for the same extension, we only trigger one build operation instead of multiple redundant builds.

Key changes:

  • Groups extension events by extension UID before processing
  • Updates all events for the same extension with the build result (success or error)
  • Maintains the same error handling and output formatting as before

How to test your changes?

  1. Run dev with multiple extensions
  2. Make simultaneous changes to the same extension
  3. Verify that only one build is triggered for multiple changes to the same extension
  4. Confirm that all events receive the correct build result

Measuring impact

How do we know this change was effective? Please choose one:

  • n/a - this doesn't need measurement, e.g. a linting rule or a bug-fix

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes

Copy link
Contributor Author

alfonso-noriega commented Oct 31, 2025

@github-actions
Copy link
Contributor

github-actions bot commented Oct 31, 2025

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
79.28% (+0.08% 🔼)
13607/17163
🟡 Branches
73.15% (+0.11% 🔼)
6651/9092
🟡 Functions
79.36% (+0.12% 🔼)
3507/4419
🟡 Lines
79.64% (+0.07% 🔼)
12852/16137
Show new covered files 🐣
St.
File Statements Branches Functions Lines
🔴
... / info.ts
0% 0% 0% 0%
🟢
... / info.ts
100% 87.5% 100% 100%
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🟢
... / loader.ts
93.86% (+0.74% 🔼)
86.7% (+1.06% 🔼)
97.06% (-0.03% 🔻)
94.67% (+0.53% 🔼)
🟢
... / ui_extension.ts
94.83% (+0.04% 🔼)
81.25% (-1.64% 🔻)
100%
96.46% (+0.03% 🔼)
🟢
... / app-event-watcher.ts
98.2% (+0.16% 🔼)
88.89% (-1.36% 🔻)
96.67% (+0.37% 🔼)
100%
🟢
... / git.ts
93.16% (+0.78% 🔼)
87.93% (-1.35% 🔻)
90.91% (+0.43% 🔼)
94.34% (+1.2% 🔼)
🟡
... / admin.ts
72.22% (-2.78% 🔻)
40% (-5.16% 🔻)
90.91%
73.58% (-2.89% 🔻)
🔴
... / dev.ts
13.04% (-0.29% 🔻)
2.94% 57.14%
13.04% (-0.29% 🔻)
🟢
... / theme-uploader.ts
91.84% (+0.12% 🔼)
78.21% (-0.83% 🔻)
86.36% (-1.14% 🔻)
93.18% (+0.59% 🔼)
🟡
... / theme-environment.ts
70.45% (-0.97% 🔻)
50%
57.89% (-0.93% 🔻)
70.45% (-0.97% 🔻)

Test suite run success

3358 tests passing in 1372 suites.

Report generated by 🧪jest coverage report action from 268feef

@alfonso-noriega alfonso-noriega force-pushed the 10-29-Group-extension-events-by-extension branch from 8e08b52 to d7ebe8d Compare October 31, 2025 12:42
@alfonso-noriega alfonso-noriega force-pushed the 10-29-avoid_problems_with_them_extensions_self_built_by_external_vite branch 2 times, most recently from 53e1e4f to a515640 Compare October 31, 2025 12:53
@alfonso-noriega alfonso-noriega force-pushed the 10-29-Group-extension-events-by-extension branch from d7ebe8d to df86305 Compare October 31, 2025 12:53
@alfonso-noriega alfonso-noriega marked this pull request as ready for review October 31, 2025 14:09
@alfonso-noriega alfonso-noriega requested a review from a team as a code owner October 31, 2025 14:09
@github-actions
Copy link
Contributor

We detected some changes at packages/*/src and there are no updates in the .changeset.
If the changes are user-facing, run pnpm changeset add to track your changes and include them in the next release CHANGELOG.

Caution

DO NOT create changesets for features which you do not wish to be included in the public changelog of the next CLI release.

@alfonso-noriega alfonso-noriega force-pushed the 10-29-Group-extension-events-by-extension branch from df86305 to 3326b7e Compare November 3, 2025 09:45
@alfonso-noriega alfonso-noriega force-pushed the 10-29-avoid_problems_with_them_extensions_self_built_by_external_vite branch from a515640 to 2c0f953 Compare November 3, 2025 09:45
@alfonso-noriega alfonso-noriega force-pushed the 10-29-Group-extension-events-by-extension branch from 3326b7e to 4e68502 Compare November 3, 2025 10:01
Copy link
Contributor

@gonzaloriestra gonzaloriestra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not working for me. I'm trying with an admin-print extension, making two changes to the en and fr locales and using Save all in the editor to save both at the same time, and I'm getting this output:

14:29:46 │               admin-print │ Build successful
14:29:46 │               admin-print │ Extension changed
14:29:46 │               admin-print │ Build successful
14:29:49 │               app-preview │ ✅ Updated app preview on gonzaloriestra-personal-dev-dd.myshopify.com
14:29:49 │               admin-print │ Extension changed
14:29:51 │               app-preview │ ✅ Updated app preview on gonzaloriestra-personal-dev-dd.myshopify.com

They shouldn't appear duplicated, right?

Copy link
Contributor Author

alfonso-noriega commented Nov 3, 2025

The changes have to be within the debounce time of the file watcher to be grouped, that is in less than 200ms aprox. It may be that you are not doing that fast enough to see them grouped?

Copy link
Contributor

The first change is not debounced, the CLI starts debouncing after the second change. This is to optimize for the most common case: a single change. If we were to debounce that, we would be adding an extra 200ms every time.

Copy link
Contributor

We could have a smaller debouncer for the first change only, like 20-30ms to catch automatic saves that modify multiple files at once 🤔

@alfonso-noriega alfonso-noriega force-pushed the 10-29-avoid_problems_with_them_extensions_self_built_by_external_vite branch from 2c0f953 to aec5821 Compare November 5, 2025 09:25
@alfonso-noriega alfonso-noriega force-pushed the 10-29-Group-extension-events-by-extension branch from 4e68502 to 5e2a2ce Compare November 5, 2025 09:25
@github-actions
Copy link
Contributor

github-actions bot commented Nov 5, 2025

Differences in type declarations

We detected differences in the type declarations generated by Typescript for this branch compared to the baseline ('main' branch). Please, review them to ensure they are backward-compatible. Here are some important things to keep in mind:

  • Some seemingly private modules might be re-exported through public modules.
  • If the branch is behind main you might see odd diffs, rebase main into this branch.

New type declarations

We found no new type declarations in this PR

Existing type declarations

packages/cli-kit/dist/private/node/analytics.d.ts
@@ -27,6 +27,5 @@ interface EnvironmentData {
 export declare function getEnvironmentData(config: Interfaces.Config): Promise<EnvironmentData>;
 export declare function getSensitiveEnvironmentData(config: Interfaces.Config): Promise<{
     env_plugin_installed_all: string;
-    env_shopify_variables: string;
 }>;
 export {};
\ No newline at end of file
packages/cli-kit/dist/private/node/api.d.ts
@@ -11,30 +11,6 @@ type RequestOptions<T> = {
     request: () => Promise<T>;
     url: string;
 } & NetworkRetryBehaviour;
-/**
- * Checks if an error is a transient network error that is likely to recover with retries.
- *
- * Use this function for retry logic. Use isNetworkError for error classification.
- *
- * Examples of transient errors (worth retrying):
- * - Connection timeouts, resets, and aborts
- * - DNS failures (enotfound, getaddrinfo, eai_again) - can be temporary
- * - Socket disconnects and hang ups
- * - Premature connection closes
- */
-export declare function isTransientNetworkError(error: unknown): boolean;
-/**
- * Checks if an error is any kind of network-related error (connection issues, timeouts, DNS failures,
- * TLS/certificate errors, etc.) rather than an application logic error.
- *
- * These errors should be reported as user-facing errors (AbortError) rather than bugs (BugError),
- * regardless of whether they are transient or permanent.
- *
- * Examples include:
- * - Transient: connection timeouts, socket hang ups, temporary DNS failures
- * - Permanent: certificate validation failures, misconfigured SSL
- */
-export declare function isNetworkError(error: unknown): boolean;
 export declare function simpleRequestWithDebugLog<T extends {
     headers: Headers;
     status: number;
packages/cli-kit/dist/public/node/metadata.d.ts
@@ -55,7 +55,6 @@ declare const coreData: RuntimeMetadataManager<CmdFieldsFromMonorail, {
     cmd_all_environment_flags?: string | null;
     cmd_dev_tunnel_custom?: string | null;
     env_plugin_installed_all?: string | null;
-    env_shopify_variables?: string | null;
 }, "store_", never>>;
 export declare const getAllPublicMetadata: () => Partial<CmdFieldsFromMonorail>, getAllSensitiveMetadata: () => Partial<{
     commandStartOptions: {
@@ -75,7 +74,6 @@ export declare const getAllPublicMetadata: () => Partial<CmdFieldsFromMonorail>,
     cmd_all_environment_flags?: string | null;
     cmd_dev_tunnel_custom?: string | null;
     env_plugin_installed_all?: string | null;
-    env_shopify_variables?: string | null;
 }, "store_", never>>, addPublicMetadata: (getData: ProvideMetadata<CmdFieldsFromMonorail>, onError?: MetadataErrorHandling) => Promise<void>, addSensitiveMetadata: (getData: ProvideMetadata<{
     commandStartOptions: {
         startTime: number;
@@ -94,7 +92,6 @@ export declare const getAllPublicMetadata: () => Partial<CmdFieldsFromMonorail>,
     cmd_all_environment_flags?: string | null;
     cmd_dev_tunnel_custom?: string | null;
     env_plugin_installed_all?: string | null;
-    env_shopify_variables?: string | null;
 }, "store_", never>>, onError?: MetadataErrorHandling) => Promise<void>, runWithTimer: (field: NumericKeyOf<CmdFieldsFromMonorail>) => <T>(fn: () => Promise<T>) => Promise<T>;
 export type Public = PublicSchema<typeof coreData>;
 export type Sensitive = SensitiveSchema<typeof coreData>;
packages/cli-kit/dist/public/node/monorail.d.ts
@@ -2,7 +2,7 @@ import { JsonMap } from '../../private/common/json.js';
 import { DeepRequired } from '../common/ts/deep-required.js';
 export { DeepRequired };
 type Optional<T> = T | null;
-export declare const MONORAIL_COMMAND_TOPIC = "app_cli3_command/1.20";
+export declare const MONORAIL_COMMAND_TOPIC = "app_cli3_command/1.19";
 export interface Schemas {
     [MONORAIL_COMMAND_TOPIC]: {
         sensitive: {
@@ -14,7 +14,6 @@ export interface Schemas {
             cmd_all_environment_flags?: Optional<string>;
             cmd_dev_tunnel_custom?: Optional<string>;
             env_plugin_installed_all?: Optional<string>;
-            env_shopify_variables?: Optional<string>;
         };
         public: {
             business_platform_id?: Optional<number>;
packages/cli-kit/dist/cli/api/graphql/admin/generated/theme_files_upsert.d.ts
@@ -8,7 +8,6 @@ export type ThemeFilesUpsertMutation = {
     themeFilesUpsert?: {
         upsertedThemeFiles?: {
             filename: string;
-            checksumMd5?: string | null;
         }[] | null;
         userErrors: {
             filename?: string | null;

@alfonso-noriega alfonso-noriega force-pushed the 10-29-avoid_problems_with_them_extensions_self_built_by_external_vite branch from aec5821 to bb52e42 Compare November 5, 2025 10:10
@alfonso-noriega alfonso-noriega force-pushed the 10-29-Group-extension-events-by-extension branch from 5e2a2ce to d724888 Compare November 5, 2025 10:10
@alfonso-noriega alfonso-noriega force-pushed the 10-29-avoid_problems_with_them_extensions_self_built_by_external_vite branch from bb52e42 to d6c771d Compare November 5, 2025 11:10
@alfonso-noriega alfonso-noriega force-pushed the 10-29-Group-extension-events-by-extension branch from d724888 to 268feef Compare November 5, 2025 11:10
Base automatically changed from 10-29-avoid_problems_with_them_extensions_self_built_by_external_vite to main November 5, 2025 11:41
@gonzaloriestra gonzaloriestra added this pull request to the merge queue Nov 5, 2025
Merged via the queue into main with commit 28fce1f Nov 5, 2025
33 of 53 checks passed
@gonzaloriestra gonzaloriestra deleted the 10-29-Group-extension-events-by-extension branch November 5, 2025 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants