fix(photon): don't kill sidecar at boot when legacy spectrum-ts dist is absent - #55387
Closed
Mengchee118 wants to merge 1 commit into
Closed
fix(photon): don't kill sidecar at boot when legacy spectrum-ts dist is absent#55387Mengchee118 wants to merge 1 commit into
Mengchee118 wants to merge 1 commit into
Conversation
…is absent
The mixed-attachment shim hard-coded node_modules/@spectrum-ts/imessage/dist
and threw a fatal Error when it was missing, which index.mjs catches and turns
into process.exit(3). After the spectrum-ts SDK layout drifted (top-level
spectrum-ts/dist + @photon-ai/* scopes), that path no longer exists, so the
sidecar died at every boot: the gateway reported 'connected' but no inbound
iMessage was ever delivered and outbound failed with 'requires a running
sidecar'.
The shim only adjusts text+multi-attachment child ordering, so a missing legacy
dist should be a no-op, not fatal. Return {patched:false} and skip gracefully
instead of throwing.
tonydwb
reviewed
Jun 30, 2026
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: LGTM
Clean 1-file fix tolerating absent legacy spectrum-ts dist in photon sidecar boot. Gracefully returns instead of killing the sidecar.
Looks Good
- Minimal fix with clear rationale
- Proper fallback (patched: false, reason provided)
- Prevents unnecessary sidecar crashes on SDK layout drift
Reviewed by Hermes Agent
teknium1
reviewed
Jul 15, 2026
teknium1
left a comment
Contributor
There was a problem hiding this comment.
Thanks for isolating the boot-failure branch.
Problems
- This adds no regression test for the new return path. The existing patch tests create
node_modules/@spectrum-ts/imessage/distattests/plugins/platforms/photon/test_spectrum_patch.py:155-160, so they do not exercise an absent directory. - Current main deliberately pins
spectrum-ts8.0.0 (plugins/platforms/photon/sidecar/package.json:16), whose lockfile contains@spectrum-ts/imessage(package-lock.json:605-621), and documents that scoped dist directory as the patch target (plugins/platforms/photon/README.md:174-183). Please establish why an installation missing that required artifact should continue without the mixed-attachment patch.
Suggested changes
- Add a temp-root Node regression test asserting that a missing dist returns nonfatally.
- Clarify the supported SDK/layout scenario, and consider aligning this narrow case with the broader nonfatal patch-failure handling proposed in #58047.
Automated hermes-sweeper review.
| // `spectrum-ts/dist` (+ `@photon-ai/*`) and no longer exposes the old | ||
| // `@spectrum-ts/imessage/dist` path this mixed-attachment shim targets. | ||
| // The shim only affects text+multi-attachment ordering; when the legacy | ||
| // path is absent, skip gracefully instead of killing the sidecar at boot. |
Contributor
There was a problem hiding this comment.
Please add a regression test that invokes this patcher against a temp root without node_modules/@spectrum-ts/imessage/dist and asserts a successful nonfatal result; the current tests only create and patch the scoped dist fixture.
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Photon Spectrum sidecar dies at every boot once the
spectrum-tsSDK layout drifts away from the legacy@spectrum-ts/imessage/distpath (e.g. after the rename to top-levelspectrum-ts/dist+@photon-ai/*scopes).patchSpectrumTs()inpatch-spectrum-mixed-attachments.mjshard-codes that legacy path and doesthrow new Error(...)when it's missing.index.mjscatches that and turns it intoprocess.exit(3)— so the sidecar exits immediately on startup.User-visible symptoms:
connected, but the status is stale — the sidecar is actually dead.Photon standalone send requires a running sidecar.Reconnect photon failed, next retry in 300s.Fix
The mixed-attachment shim only adjusts text + multi-attachment child ordering, so a missing legacy
distshould be a no-op — not fatal. Return{ patched: false }and skip gracefully instead of throwing. Thespectrum-tspackage itself is intact in this scenario; only the patch's hard-coded old path is stale.if (!fs.existsSync(dist)) { - throw new Error(`@spectrum-ts/imessage dist not found: ${dist}`); + // Layout drift: newer spectrum-ts ships as top-level spectrum-ts/dist + // (+ @photon-ai/* scopes) and no longer exposes @spectrum-ts/imessage/dist. + // The shim only affects text+multi-attachment ordering; skip gracefully + // instead of killing the sidecar at boot. + return { patched: false, reason: "legacy @spectrum-ts/imessage dist absent" }; }Test plan
[photon] connected — streaming inbound over gRPCappears in the gateway log./healthzreturns{"ok":false,"error":"unauthorized"}(alive + enforcing the sidecar token).@photon-ai/*scopes present,@spectrum-ts/imessage/distabsent).