Skip to content

fix(harmonyos): narrow the unsupported-stream error before reporting it - #3147

Merged
wgqqqqq merged 1 commit into
GCWing:mainfrom
wgqqqqq:wgq/fix-harmonyos-stream-error-typing
Sep 20, 2026
Merged

wgqqqqq merged 1 commit into
GCWing:mainfrom
wgqqqqq:wgq/fix-harmonyos-stream-error-typing

Conversation

@wgqqqqq

@wgqqqqq wgqqqqq commented Sep 20, 2026

Copy link
Copy Markdown
Collaborator

Summary

The HarmonyOS entry module does not compile on current DevEco SDKs: assembleHap stops at entry/src/main/ets/services/HostSessionStream.ets:265 with

10605030 ArkTS Compiler Error
Structural typing is not supported (arkts-no-structural-typing)

This already fails on main (e0b8ae60d), so nobody can build or install the HarmonyOS app from the default branch. The PR adds the one missing type narrowing that makes the module compile again.

HostSessionStream.catchUp hands the caught value to HostSessionCallbacks.onError, which is typed (error: Error) => void. The HostStreamUnsupportedError branch passed error unchanged and relied on implicit structural assignability, which ArkTS rejects. The sibling branch two lines below already narrows with error as Error; this PR does the same in the unsupported-stream branch.

Fixes: no issue filed — found while building the app for a device.

Type and Areas

Type: bug fix (compile regression)

Areas: HarmonyOS mobile app (src/apps/mobile/harmonyos)

Motivation / Impact

  • Before: assembleHap fails, so the HarmonyOS app cannot be built or installed from main at all.
  • After: the module compiles, and the produced HAP installs and launches on real hardware.
  • No runtime behavior change: the same error object still reaches onError, and the following close() and retry paths are untouched.

Verification

  • source scripts/ohos-env.sh && "$HVIGORW" --mode module -p product=default -p module=entry@default assembleHap --no-daemon
    • before: BUILD FAILED — 1 ERROR: 10605030 ArkTS Compiler Error ... At File: .../services/HostSessionStream.ets:265:32
    • after: BUILD SUCCESSFUL (produces entry-default-signed.hap, 8.79 MB)
  • Real device HUAWEI DEL-AL10 (HarmonyOS 6.1.0.135, API 24):
    • hdc install -r entry/build/default/outputs/default/entry-default-signed.hap → install bundle successfully
    • hdc shell aa start -b com.bitfun.app -a EntryAbility → start ability successfully; the home screen renders and lists the connected host.
  • pnpm run harmony:architecture → HarmonyOS architecture contracts are satisfied.
  • Not exercised: the HostStreamUnsupportedError runtime branch itself, which needs an older host that rejects read_stream. The change is a compile-time annotation only.

Reviewer Notes

The narrowed branch is only reachable when a host answers read_stream with an unknown-command rejection; the object passed to onError is the same one as before. Rollback is a one-line revert with no data or compatibility impact.

AI-assisted: yes. Testing level: fully tested for the reported failure (build + device install + launch); the runtime branch was not exercised.

Checklist

  • This PR is focused and does not include secrets, temporary prompts, generated scratch files, or unrelated artifacts.
  • Relevant verification is recorded above, or skipped checks are explained.
  • User-facing strings, docs, and locales are updated where applicable. (Not applicable: no copy, docs, or locale keys change.)

`HostSessionStream.catchUp` hands the caught value to
`HostSessionCallbacks.onError`, which is typed `(error: Error) => void`.
The `HostStreamUnsupportedError` branch passed `error` unchanged and relied
on implicit structural assignability, which ArkTS rejects, so `assembleHap`
failed on current SDKs:

    10605030 ArkTS Compiler Error
    Structural typing is not supported (arkts-no-structural-typing)
    At File: entry/src/main/ets/services/HostSessionStream.ets:265:32

The sibling branch two lines below already narrows with `error as Error`.
Do the same in the unsupported-stream branch. The reported error, the
`close()` that follows, and the retry path are all unchanged.
@wgqqqqq
wgqqqqq merged commit d75efb1 into GCWing:main Sep 20, 2026
9 checks passed
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