Skip to content

Conversation

@ericlee878
Copy link
Contributor

@ericlee878 ericlee878 commented Dec 11, 2025

Summary

Adds a new shopify app bulk cancel command to cancel running bulk operations, complementing the existing bulk execute and bulk status commands.

Usage

# Cancel by positional argument
shopify app bulk cancel gid://shopify/BulkOperation/123

# Cancel by flag
shopify app bulk cancel --id gid://shopify/BulkOperation/123

# With store flag
shopify app bulk cancel gid://shopify/BulkOperation/123 --store my-store.myshopify.com

Implementation Details

  • ID accepts both flag and positional argument

    • The operation ID can be provided as --id flag or as a positional argument for ergonomics:
    shopify app bulk cancel gid://shopify/BulkOperation/123  # positional
    shopify app bulk cancel --id gid://shopify/BulkOperation/123  # flag
    
  • Status-aware result messaging

    • The command renders different UI based on what state the operation is in after the cancel request.
  • API version hardcoded 2026-01

    • This can be changed when the API version handling PR is merged.
  • Should we add a --watch flag to this?

Testing

  1. Create a large Bulk Operation
  • Ask cursor to build a large variable-file. It should look like this but with much more variables:
{"input":{"title":"Test Product 1","descriptionHtml":"<p>This is test product 1</p>","productType":"Test Type","vendor":"Test Vendor","tags":["bulk","test"],"metafields":[{"namespace":"custom","key":"field1","value":"value1","type":"single_line_text_field"},{"namespace":"custom","key":"field2","value":"value2","type":"single_line_text_field"},{"namespace":"custom","key":"field3","value":"value3","type":"single_line_text_field"}]}}
{"input":{"title":"Test Product 2","descriptionHtml":"<p>This is test product 2</p>","productType":"Test Type","vendor":"Test Vendor","tags":["bulk","test"],"metafields":[{"namespace":"custom","key":"field1","value":"value1","type":"single_line_text_field"},{"namespace":"custom","key":"field2","value":"value2","type":"single_line_text_field"},{"namespace":"custom","key":"field3","value":"value3","type":"single_line_text_field"}]}}
  • Run this command:
pnpm shopify:run app bulk execute --path ./coffee-and-more --variable-file large-variables.jsonl -q 'mutation productCreate($input: ProductInput!) {
    productCreate(input: $input) {
      product {
        id
        title
        metafields(first: 10) {
          edges {
            node {
              id
              namespace
              key
              value
            }
          }
        }
      }
      userErrors {
        field
        message
      }
    }
  }'

This should show.
Screenshot 2025-12-10 at 4.37.40 PM.png

Save the bulk operation id somewhere.

  1. Cancel the Bulk Operation
  • Run the command
pnpm shopify:run app bulk cancel \
  --path ./coffee-and-more \
  --id gid://shopify/BulkOperation/<bulk_operation_id>

This should show.

Screenshot 2025-12-10 at 4.42.48 PM.png

  1. Check the status of the bulk operation
  • Run the command
pnpm shopify:run app bulk status \
  --path ./coffee-and-more \
  --id gid://shopify/BulkOperation/6578182226092

This should show.

Screenshot 2025-12-10 at 4.43.39 PM.png

Copy link
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 11, 2025

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
79.49% (+0.26% 🔼)
14203/17868
🟡 Branches
73.6% (+0.49% 🔼)
6970/9470
🟡 Functions
79.64% (+0.27% 🔼)
3642/4573
🟡 Lines
79.86% (+0.28% 🔼)
13428/16815
Show new covered files 🐣
St.
File Statements Branches Functions Lines
🟢
... / admin-as-app.ts
100% 100% 100% 100%
🟢
... / metafield_definitions.ts
100% 100% 100% 100%
🟢
... / metaobject_definitions.ts
100% 100% 100% 100%
🟢
... / bulk-operation-cancel.ts
100% 100% 100% 100%
🟢
... / bulk-operation-run-mutation.ts
100% 100% 100% 100%
🟢
... / bulk-operation-run-query.ts
100% 100% 100% 100%
🟢
... / get-bulk-operation-by-id.ts
100% 100% 100% 100%
🟢
... / list-bulk-operations.ts
100% 100% 100% 100%
🟢
... / staged-uploads-create.ts
100% 100% 100% 100%
🔴
... / cancel.ts
0% 100% 0% 0%
🔴
... / execute.ts
0% 0% 0% 0%
🔴
... / status.ts
0% 0% 0% 0%
🔴
... / pull.ts
0% 100% 0% 0%
🟢
... / execute-operation.ts
92.59% 75% 100% 92.31%
🔴
... / pull.ts
0% 0% 0% 0%
🟢
... / bulk-operation-status.ts
96.55% 92.11% 100% 100%
🟢
... / cancel-bulk-operation.ts
100% 100% 100% 100%
🟢
... / constants.ts
100% 100% 100% 100%
🟢
... / download-bulk-operation-results.ts
100% 100% 100% 100%
🟢
... / execute-bulk-operation.ts
92.54% 86.67% 100% 93.85%
🟢
... / format-bulk-operation-status.ts
100% 100% 100% 100%
🟢
... / run-mutation.ts
100% 100% 100% 100%
🟢
... / run-query.ts
100% 100% 100% 100%
🟡
... / stage-file.ts
73.53% 62.5% 85.71% 72.73%
🟢
... / watch-bulk-operation.ts
100% 94.74% 100% 100%
🟢
... / declarative-definitions.ts
98.54% 93.18% 100% 98.51%
🟢
... / common.ts
97.22% 93.75% 100% 96.55%
🟢
... / execute-command-helpers.ts
100% 100% 100% 100%
🔴
... / promiseWithResolvers.ts
33.33% 50% 50% 33.33%
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🔴
... / execute.ts
0%
0% (-100% 🔻)
0% 0%
🟢
... / extension-instance.ts
84.8% (+0.23% 🔼)
77.6% (-0.91% 🔻)
92.06% (+0.13% 🔼)
85.11% (+0.24% 🔼)
🟡
... / specification.ts
69.09%
75.61% (+2.44% 🔼)
76.47% (-1.31% 🔻)
68.75%
🟢
... / ui_extension.ts
85.38% (-9.44% 🔻)
72.34% (-8.91% 🔻)
84% (-16% 🔻)
88% (-8.46% 🔻)
🟢
... / developer-platform-client.ts
84.62% (-1.5% 🔻)
71.43% (+0.84% 🔼)
81.82% (+1.82% 🔼)
93.75% (+0.42% 🔼)
🟢
... / api.ts
87.07% (-0.43% 🔻)
76.71% (-0.1% 🔻)
100%
86.49% (-0.43% 🔻)
🟢
... / ConcurrentOutput.tsx
98.36% (-1.64% 🔻)
92% (-4% 🔻)
100%
98.33% (-1.67% 🔻)
🟢
... / SingleTask.tsx
84.21% (-15.79% 🔻)
50% (-50% 🔻)
80% (-20% 🔻)
84.21% (-15.79% 🔻)
🔴
... / environment.ts
35% (-5% 🔻)
41.18%
40% (-10% 🔻)
36.84% (-5.26% 🔻)
🔴
... / ui.tsx
50.82% (-0.79% 🔻)
42.86% (-5.53% 🔻)
54.55% (+1.42% 🔼)
50% (-0.82% 🔻)
🟢
... / console.ts
81.82% (+15.15% 🔼)
75% (-25% 🔻)
100% (+33.33% 🔼)
81.82% (+15.15% 🔼)
🔴
... / dev.ts
14.29% (+0.95% 🔼)
3.13% (+0.18% 🔼)
50% (-7.14% 🔻)
14.29% (+0.95% 🔼)
🟢
... / init.ts
88% (-0.89% 🔻)
71.43% (+4.76% 🔼)
86.67% (+4.85% 🔼)
88% (-0.89% 🔻)
🟢
... / storefront-renderer.ts
90.2% (-0.54% 🔻)
78.95%
81.82% (-1.52% 🔻)
90.2% (-0.54% 🔻)
🟡
... / theme-polling.ts
67.12% (-0.93% 🔻)
68.75% 78.57%
66.67% (-0.98% 🔻)

Test suite run success

3573 tests passing in 1419 suites.

Report generated by 🧪jest coverage report action from 839f44a

@ericlee878 ericlee878 marked this pull request as ready for review December 11, 2025 00:43
@ericlee878 ericlee878 requested review from a team as code owners December 11, 2025 00:43
@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.

@ericlee878 ericlee878 force-pushed the add-shopify-app-bulk-cancel-command branch from f696432 to a89e033 Compare December 11, 2025 00:56
@ericlee878 ericlee878 changed the title shopify app bulk cancel command to cancel bulkops through CLI shopify app bulk cancel command to cancel bulkops through CLI Dec 11, 2025
@ericlee878 ericlee878 force-pushed the add-shopify-app-bulk-cancel-command branch 2 times, most recently from 9c7c1cc to d860661 Compare December 11, 2025 21:48
@ericlee878 ericlee878 force-pushed the add-shopify-app-bulk-cancel-command branch 3 times, most recently from 6b60777 to dcc981b Compare December 13, 2025 01:00
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.

Some general feedback/doubts:

  • Is there a limit in the number of simultaneous bulk operations? Otherwise, why would the users want to cancel?
  • Why does it take so long to cancel? I would find it annoying to need another bulk operation for that. I think it should be almost instant, at least from the user perspective. If the server really need some time, couldn't we tell the user it's canceled and finish the work silently in the backend?

@ericlee878 ericlee878 force-pushed the add-shopify-app-bulk-cancel-command branch 3 times, most recently from 3696913 to 886a15d Compare December 15, 2025 22:31
Copy link
Contributor Author

Not too sure about this. I think @allancalix will have more context. But for the limit in the number of simultaneous bulk operations part, I'm pretty sure you can only run one bulk operation per shop at a time.

Copy link

@gonzaloriestra We allow at most 5 bulk mutations at any time per app. Most of the bulk operation use cases are async and offline, we didn't consider how a recent change we made to allow bulk mutation jobs to run longer would cause delays for cancellation (cc: @teddyhwang). There are things we can do to improve this but this is the first we have heard of cancellation delay causing issues so we'll have to make changes to lower the latency on it.

@gonzaloriestra
Copy link
Contributor

We allow at most 5 bulk mutations at any time per app.

In that case, I suspect this command would almost never be used... But it's ok to keep it.

Also, if the cancellation is going to be fast, I think the command should be sync (similar to app execute) instead of creating another bulk operation that you have to monitor. What do you think?

@nickwesselman
Copy link
Contributor

Initiating a cancel is sync, but the process is async. It will take time for the job to respond to the cancel "request." I think the output of cancel in the screenshot above though looks too much like a new job has been created.

Let's use the info banner to confirm inputs -- especially in the case that there is an error due to a bad ID or having the wrong app/store context. Then use the success banner to confirm that the cancellation was initiated, set expectations, and tell them how to check on it.

┌─ info ───────────────────────────────────────────────────────┐
│                                                              │
│  Canceling bulk operation.                                   │
│                                                              │
│  • ID: gid://shopify/BulkOperation/6578182226092             │
│  • Organization: Coffee & More                               │
│  • App: coffee-and-more                                      │
│  • Store: coffee-and-more-1851.myshopify.com                 │
│                                                              │
└──────────────────────────────────────────────────────────────┘

┌─ success ────────────────────────────────────────────────────┐
│                                                              │
│  Bulk operation is being cancelled.                          │
│                                                              │
│  This may take a few moments to complete. To check the       │
│  status of the operation, run:                               │
│  `shopify app bulk status --id=6578182226092`                │
│                                                              │
└──────────────────────────────────────────────────────────────┘

@ericlee878 ericlee878 force-pushed the add-shopify-app-bulk-cancel-command branch 2 times, most recently from 2f0263f to 668499a Compare December 17, 2025 00:04
Copy link
Contributor Author

@nickwesselman Made the changes to reflect this!

@ericlee878 ericlee878 force-pushed the add-shopify-app-bulk-cancel-command branch from 668499a to 2aa6bd5 Compare December 17, 2025 18:35
Copy link
Contributor

/snapit

@ericlee878 ericlee878 force-pushed the add-shopify-app-bulk-cancel-command branch 2 times, most recently from e8d1e85 to fb7dd29 Compare December 17, 2025 22:46
@ericlee878 ericlee878 force-pushed the add-shopify-app-bulk-cancel-command branch from fb7dd29 to 839f44a Compare December 17, 2025 22:55
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 working well. Although after a while, when trying to get the status of a canceled operation, I get Bulk operation not found. Is that related to the token issue you are aware?

Also, I think I already mentioned this, but I think you should add a --query-file flag. Update: this is added by #6733

@ericlee878 ericlee878 added this pull request to the merge queue Dec 18, 2025
Merged via the queue into main with commit f594242 Dec 18, 2025
25 checks passed
@ericlee878 ericlee878 deleted the add-shopify-app-bulk-cancel-command branch December 18, 2025 19: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.

4 participants