Skip to content

Conversation

@v0eak
Copy link
Contributor

@v0eak v0eak commented Oct 28, 2025

Summary

What
Change req.query to req.params in appropriate api routes

  • move /api/admin/workflows-executions/[workflow_id]/[transaction_id]/[step_id]/subscribe/route.ts
    to /api/admin/workflows-executions/[workflow_id]/[transaction_id]/subscribe/route.ts, because it is not possible to subscribe to individual steps, only to individual workflows.
  • modify API reference in documentation to mirror changes

Why — Current implementation relies on req.query to get the id of workflow/transaction, but it should get them from req.params instead

How — Change req.query to req.params

Testinghttps://docs.medusajs.com/api/admin#workflows-executions_getworkflowsexecutionsworkflow_idsubscribe

Examples

https://docs.medusajs.com/resources/js-sdk#stream-server-sent-events

// Example usage

Checklist

Please ensure the following before requesting a review:

  • I have added a changeset for this PR
    • Every non-breaking change should be marked as a patch
    • To add a changeset, run yarn changeset and follow the prompts
  • The changes are covered by relevant tests
  • I have verified the code works as intended locally
  • I have linked the related issue(s) if applicable

Additional Context

Add any additional context, related issues, or references that might help the reviewer understand this PR.


Note

Switch admin workflow subscription to path params and a single-execution endpoint; update JS SDK fetchStream to always yield a stream and throw on non-OK, with docs aligned.

  • API (Medusa)
    • Use req.params instead of req.query in admin/workflows-executions/[workflow_id]/[transaction_id]/subscribe and [workflow_id]/subscribe routes.
    • Remove step-level subscription; consolidate to .../[workflow_id]/[transaction_id]/subscribe.
  • JS SDK
    • Update client.fetchStream to return a non-null async generator; defer fetch, throw HttpError on non-OK, and stream via events with abort support.
    • Adjust FetchStreamResponse type: stream is non-null.
  • Docs
    • Revise API reference path/summary and cURL sample to match consolidated endpoint.
    • Update JS SDK examples: remove null checks for stream and handle HttpError by calling abort.
  • Changeset
    • @medusajs/medusa: minor; @medusajs/js-sdk: patch.

Written by Cursor Bugbot for commit c9137d9. This will update automatically on new commits. Configure here.

@v0eak v0eak requested review from a team as code owners October 28, 2025 16:13
@changeset-bot
Copy link

changeset-bot bot commented Oct 28, 2025

🦋 Changeset detected

Latest commit: c9137d9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 74 packages
Name Type
@medusajs/medusa Major
@medusajs/js-sdk Major
@medusajs/test-utils Major
@medusajs/medusa-oas-cli Major
integration-tests-http Patch
@medusajs/draft-order Major
@medusajs/dashboard Major
@medusajs/analytics Major
@medusajs/api-key Major
@medusajs/auth Major
@medusajs/caching Major
@medusajs/cart Major
@medusajs/currency Major
@medusajs/customer Major
@medusajs/file Major
@medusajs/fulfillment Major
@medusajs/index Major
@medusajs/inventory Major
@medusajs/link-modules Major
@medusajs/locking Major
@medusajs/notification Major
@medusajs/order Major
@medusajs/payment Major
@medusajs/pricing Major
@medusajs/product Major
@medusajs/promotion Major
@medusajs/region Major
@medusajs/sales-channel Major
@medusajs/settings Major
@medusajs/stock-location Major
@medusajs/store Major
@medusajs/tax Major
@medusajs/user Major
@medusajs/workflow-engine-inmemory Major
@medusajs/workflow-engine-redis Major
@medusajs/oas-github-ci Major
@medusajs/admin-bundler Major
@medusajs/cache-inmemory Major
@medusajs/cache-redis Major
@medusajs/event-bus-local Major
@medusajs/event-bus-redis Major
@medusajs/analytics-local Major
@medusajs/analytics-posthog Major
@medusajs/auth-emailpass Major
@medusajs/auth-github Major
@medusajs/auth-google Major
@medusajs/caching-redis Major
@medusajs/file-local Major
@medusajs/file-s3 Major
@medusajs/fulfillment-manual Major
@medusajs/locking-postgres Major
@medusajs/locking-redis Major
@medusajs/notification-local Major
@medusajs/notification-sendgrid Major
@medusajs/payment-stripe Major
@medusajs/core-flows Major
@medusajs/framework Major
@medusajs/modules-sdk Major
@medusajs/orchestration Major
@medusajs/types Major
@medusajs/utils Major
@medusajs/workflows-sdk Major
@medusajs/cli Major
@medusajs/deps Major
@medusajs/telemetry Major
@medusajs/admin-sdk Major
@medusajs/admin-shared Major
@medusajs/admin-vite-plugin Major
@medusajs/icons Major
@medusajs/toolbox Major
@medusajs/ui-preset Major
create-medusa-app Major
medusa-dev-cli Major
@medusajs/ui Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Oct 28, 2025

@v0eak is attempting to deploy a commit to the medusajs Team on Vercel.

A member of the Team first needs to authorize it.

Refactor fetch handling to use a promise and async generator for streaming response.
cursor[bot]

This comment was marked as outdated.

@v0eak
Copy link
Contributor Author

v0eak commented Oct 29, 2025

Also modified the js-sdk to return before it receives its first body response, because otherwise, when a stream is established, its not possible to abort it until data is sent. in the case of workflow subscriptions, this might take a while. If we then have a component that would like to unmount its stream, it is unable to, because it has not yet received its first data.
In the example provided here, we can only abort after first data received, because

    const { stream, abort } = await sdk.client.fetchStream("/admin/stream")
    setAbortStream(() => abort)

abortStream will not be set until the await fetchStream resolves.

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.

1 participant