Skip to content

Fix package artifact rebuild diagnostics - #560

Merged
kentcdodds merged 2 commits into
mainfrom
cursor/package-artifact-rebuild-failure-ac60
Jun 25, 2026
Merged

kentcdodds merged 2 commits into
mainfrom
cursor/package-artifact-rebuild-failure-ac60

Conversation

@kentcdodds

@kentcdodds kentcdodds commented Jun 25, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Share package artifact target collection between publish-time checks and artifact persistence so package_publish_external_push validates the same module/importable/app targets it will later persist.
  • Improve artifact rebuild failures to include the failing target identity and nested cause chain.
  • Retry package_publish_external_push when a transient Durable Object reset is wrapped inside an artifact rebuild error cause.
  • Extract shared error cause-chain traversal helpers after CodeRabbit feedback.

Validation

  • npm test -- --run packages/worker/src/repo/checks.node.test.ts packages/worker/src/package-runtime/published-bundle-artifacts.node.test.ts packages/worker/src/mcp/capabilities/packages/publish-external-push.node.test.ts
  • npm run format:check
  • npm run lint (0 errors; existing unrelated warnings only)
  • npm run typecheck
  • npm run validate (latest local run: 120 test files / 386 tests passed)

Production / operations

No schema migration is required. This prevents future publishes from advancing source state when persisted bundle artifacts would fail to build, and makes any rebuild failure identify the exact target/cause. For an already-stuck production package whose published_commit was advanced without usable artifacts, re-run package_publish_external_push after the package source is corrected; if the commit itself is invalid for persisted module artifacts, publish a corrected commit or manually restore entity_sources.published_commit to the last known-good commit and re-run publish.

Open in Web Open in Cursor 

Summary by CodeRabbit

  • New Features

    • Package publish checks now validate a broader set of published runtime artifact targets, including app, module, and importable-module builds.
  • Bug Fixes

    • Improved retry recovery when publish encounters transient Durable Object reset errors.
    • Publish failure messages are more detailed, including the specific target that failed and a full nested “Caused by” error chain for easier debugging.

Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
@coderabbitai

coderabbitai Bot commented Jun 25, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 35eeaf5d-83a8-4566-9e3d-70ef34296eec

📥 Commits

Reviewing files that changed from the base of the PR and between bee39cd and dcf7c5d.

📒 Files selected for processing (3)
  • packages/worker/src/mcp/capabilities/error-message.ts
  • packages/worker/src/mcp/capabilities/packages/publish-external-push.ts
  • packages/worker/src/mcp/capabilities/repo/package-artifact-rebuild.ts

📝 Walkthrough

Walkthrough

Published package artifact targets are extracted into a shared module, repo checks consume those targets for bundle validation, and rebuild/publish error handling now includes nested cause chains and transient Durable Object reset retries.

Changes

Published package artifact target and publish error flow

Layer / File(s) Summary
Target helper extraction
packages/worker/src/package-runtime/package-artifact-targets.ts, packages/worker/src/package-runtime/published-bundle-artifacts.ts, packages/worker/src/package-runtime/published-bundle-artifacts.node.test.ts
A new target module defines published artifact build targets, the target collector moves there, and the published-bundle-artifacts export surface re-exports the helper and type.
Repo checks target mapping
packages/worker/src/repo/checks.ts
Repo checks switch to published artifact targets, map artifact bundle kinds into internal bundle kinds, and keep the callable typecheck target collection signature aligned.
Repo checks test updates
packages/worker/src/repo/checks.node.test.ts
The repo checks tests now cover persisted package artifact target validation, updated bundle counts, and the expected build calls for the new target flow.
Rebuild failure formatting
packages/worker/src/mcp/capabilities/repo/package-artifact-rebuild.ts, packages/worker/src/mcp/capabilities/packages/publish-external-push.node.test.ts
Rebuild failures are wrapped with standardized messages that include source, commit, optional target details, and chained causes, and the rebuild failure test asserts the new message shape.
Transient reset retry
packages/worker/src/mcp/capabilities/error-message.ts, packages/worker/src/mcp/capabilities/packages/publish-external-push.ts, packages/worker/src/mcp/capabilities/packages/publish-external-push.node.test.ts
Transient Durable Object reset detection now walks nested cause chains, and the publish retry test verifies a warning plus a second rebuild attempt.

Sequence Diagram(s)

sequenceDiagram
  participant publishExternalPushCapability
  participant isTransientDurableObjectResetError
  participant rebuildPublishedPackageArtifactsViaRepoSession
  participant rebuildPublishedPackageArtifact

  publishExternalPushCapability->>rebuildPublishedPackageArtifactsViaRepoSession: start external publish rebuild
  rebuildPublishedPackageArtifactsViaRepoSession->>rebuildPublishedPackageArtifact: rebuild target
  rebuildPublishedPackageArtifact-->>rebuildPublishedPackageArtifactsViaRepoSession: Error(cause chain)
  rebuildPublishedPackageArtifactsViaRepoSession-->>publishExternalPushCapability: throw rebuild failure
  publishExternalPushCapability->>isTransientDurableObjectResetError: inspect nested cause chain
  isTransientDurableObjectResetError-->>publishExternalPushCapability: true
  publishExternalPushCapability->>publishExternalPushCapability: warn transient Durable Object reset
  publishExternalPushCapability->>rebuildPublishedPackageArtifactsViaRepoSession: retry external publish flow
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • kentcdodds/kody#352: Adds the external publish flow that this PR extends with retry and rebuild-failure handling.
  • kentcdodds/kody#363: Also updates repo/checks.ts around bundle-target collection and bundle kind mapping.
  • kentcdodds/kody#427: Relates to the same transient Durable Object reset handling path in publish-external-push.

Poem

I hop through targets, neat and bright,
And sniff the causes in the night.
If resets grumble, I try once more,
Then bundle bunnies bound to shore. 🐇
Thump! The publish trail lands right.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately reflects the main change: improving package artifact rebuild diagnostics.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/package-artifact-rebuild-failure-ac60

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@kentcdodds
kentcdodds marked this pull request as ready for review June 25, 2026 12:24
@github-actions

github-actions Bot commented Jun 25, 2026 •

Copy link
Copy Markdown
Contributor

🔎 Preview deployed: https://kody-pr-560.kentcdodds.workers.dev

Worker: kody-pr-560
D1: kody-pr-560-db
KV: kody-pr-560-oauth-kv

Mocks:

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/worker/src/mcp/capabilities/repo/package-artifact-rebuild.ts (1)

5-22: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicated error-cause helpers across capabilities.

getErrorCause here is identical to the one in packages/worker/src/mcp/capabilities/packages/publish-external-push.ts (Lines 31-36), and formatErrorCauseChain shares the same seen-guarded error -> cause traversal as that file's errorCauseChainIncludes. Since both files participate in the same publish/rebuild flow, consider extracting a shared getErrorCause + a single cause-chain walker (e.g. alongside error-message.ts) so the traversal/cycle-guard logic stays consistent.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/worker/src/mcp/capabilities/repo/package-artifact-rebuild.ts` around
lines 5 - 22, The error-cause traversal helpers in getErrorCause and
formatErrorCauseChain are duplicated and should be shared with the similar logic
in publish-external-push.ts. Extract a common getErrorCause plus a single
cause-chain walker/helper near the existing error-message utilities, then update
package-artifact-rebuild.ts to use it so the seen-guarded error->cause traversal
stays consistent across both capabilities.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/worker/src/mcp/capabilities/repo/package-artifact-rebuild.ts`:
- Around line 5-22: The error-cause traversal helpers in getErrorCause and
formatErrorCauseChain are duplicated and should be shared with the similar logic
in publish-external-push.ts. Extract a common getErrorCause plus a single
cause-chain walker/helper near the existing error-message utilities, then update
package-artifact-rebuild.ts to use it so the seen-guarded error->cause traversal
stays consistent across both capabilities.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 62573319-8b3b-4f33-b24a-cd779b616dc7

📥 Commits

Reviewing files that changed from the base of the PR and between 297be7a and bee39cd.

📒 Files selected for processing (8)
  • packages/worker/src/mcp/capabilities/packages/publish-external-push.node.test.ts
  • packages/worker/src/mcp/capabilities/packages/publish-external-push.ts
  • packages/worker/src/mcp/capabilities/repo/package-artifact-rebuild.ts
  • packages/worker/src/package-runtime/package-artifact-targets.ts
  • packages/worker/src/package-runtime/published-bundle-artifacts.node.test.ts
  • packages/worker/src/package-runtime/published-bundle-artifacts.ts
  • packages/worker/src/repo/checks.node.test.ts
  • packages/worker/src/repo/checks.ts

Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
@kentcdodds
kentcdodds merged commit c36728a into main Jun 25, 2026
5 checks passed
@kentcdodds
kentcdodds deleted the cursor/package-artifact-rebuild-failure-ac60 branch June 25, 2026 12:39
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.

2 participants