Skip to content

error controller#770

Merged
cehan-Chloe merged 24 commits into
player-1-dot-zerofrom
error-controller
May 6, 2026
Merged

error controller#770
cehan-Chloe merged 24 commits into
player-1-dot-zerofrom
error-controller

Conversation

@cehan-Chloe
Copy link
Copy Markdown
Contributor

@cehan-Chloe cehan-Chloe commented Dec 9, 2025

Define error controller types and hooks

Change Type (required)

Indicate the type of change your pull request is:

  • patch
  • minor
  • major
  • N/A

Does your PR have any documentation updates?

  • Updated docs
  • No Update needed
  • Unable to update docs

Release Notes

Error Controller

Player now has a built-in ErrorController, instantiated automatically when a flow starts and accessible via controllers.error on all platforms.

Core API

captureError(error) accepts any error implementing the PlayerErrorMetadata interface (type, optional severity, optional metadata). It fires the onError bail hook, writes to errorState in the data model, and navigates via errorTransitions. Returns true if the error was handled (hook bailed or an errorTransitions route was navigated), false if the flow was failed.

onError is a bail hook — returning true takes ownership of the error, preventing errorState from being written and navigation from occurring. Additional state inspection methods: getCurrentError(), getErrors(), clearErrors(), clearCurrentError().

Error Navigation

Flows can define errorTransitions at the node or flow level to route errors to dedicated error views instead of failing the flow:

{ "errorTransitions": { "render": "RENDER_ERROR_VIEW", "*": "GENERIC_ERROR_VIEW" } }
Node-level takes precedence over flow-level. The "*" wildcard matches any unhandled type.

Render-Time Error Capture

Capture asset render errors. Each platform provides an AssetRenderError / AssetRenderException with the failing asset id and full parent path in the error message

@cehan-Chloe cehan-Chloe marked this pull request as ready for review December 10, 2025 14:00
@cehan-Chloe cehan-Chloe requested a review from a team as a code owner December 10, 2025 14:00
Comment thread core/player/src/controllers/error/controller.ts Outdated
Comment thread core/player/src/controllers/error/controller.ts Outdated
Comment thread core/player/src/controllers/error/controller.ts
Comment thread core/player/src/controllers/error/controller.ts Outdated
@cehan-Chloe cehan-Chloe marked this pull request as draft December 11, 2025 15:53
Comment thread core/player/src/controllers/error/controller.ts
@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (f77e224) to head (580ad8a).
⚠️ Report is 2 commits behind head on player-1-dot-zero.

Additional details and impacted files
@@           Coverage Diff            @@
##   player-1-dot-zero   #770   +/-   ##
========================================
========================================

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 11, 2025

Bundle Report

Changes will increase total bundle size by 247.66kB (5.45%) ⬆️⚠️, exceeding the configured threshold of 5%.

Bundle name Size Change
plugins/beacon/core 424.16kB 20.76kB (5.15%) ⬆️⚠️
plugins/check-path/core 442.56kB 20.76kB (4.92%) ⬆️
react/subscribe 13.68kB 2.04kB (17.56%) ⬆️⚠️
plugins/reference-assets/core 554.86kB 40.6kB (7.89%) ⬆️⚠️
react/player 83.75kB 10.21kB (13.88%) ⬆️⚠️
plugins/markdown/core 683.22kB 20.77kB (3.14%) ⬆️
plugins/metrics/core 460.72kB 20.76kB (4.72%) ⬆️
plugins/async-node/core 504.21kB 44.75kB (9.74%) ⬆️⚠️
plugins/external-action/core* 19.83kB 709 bytes (3.71%) ⬆️
core/player 1.02MB 66.3kB (6.95%) ⬆️⚠️

ℹ️ *Bundle size includes cached data from a previous commit

Affected Assets, Files, and Routes:

view changes for bundle: plugins/markdown/core

Assets Changed:

Asset Name Size Change Total Size Change (%)
MarkdownPlugin.native.js 20.77kB 658.07kB 3.26%
view changes for bundle: plugins/reference-assets/core

Assets Changed:

Asset Name Size Change Total Size Change (%)
ReferenceAssetsPlugin.native.js 33.64kB 516.88kB 6.96% ⚠️
cjs/index.cjs 2.33kB 13.97kB 20.0% ⚠️
index.legacy-esm.js 2.31kB 12.01kB 23.87% ⚠️
index.mjs 2.31kB 12.01kB 23.87% ⚠️
view changes for bundle: plugins/external-action/core

Assets Changed:

Asset Name Size Change Total Size Change (%)
ExternalActionPlugin.native.js 412 bytes 13.13kB 3.24%
cjs/index.cjs 99 bytes 2.92kB 3.51%
index.legacy-esm.js 99 bytes 1.89kB 5.52% ⚠️
index.mjs 99 bytes 1.89kB 5.52% ⚠️
view changes for bundle: core/player

Assets Changed:

Asset Name Size Change Total Size Change (%)
Player.native.js 23.11kB 426.3kB 5.73% ⚠️
cjs/index.cjs 14.61kB 202.24kB 7.79% ⚠️
index.legacy-esm.js 14.29kB 195.51kB 7.89% ⚠️
index.mjs 14.29kB 195.51kB 7.89% ⚠️
view changes for bundle: plugins/metrics/core

Assets Changed:

Asset Name Size Change Total Size Change (%)
MetricsPlugin.native.js 20.76kB 428.38kB 5.09% ⚠️
view changes for bundle: plugins/beacon/core

Assets Changed:

Asset Name Size Change Total Size Change (%)
BeaconPlugin.native.js 20.76kB 409.69kB 5.34% ⚠️
view changes for bundle: plugins/async-node/core

Assets Changed:

Asset Name Size Change Total Size Change (%)
AsyncNodePlugin.native.js 29.98kB 441.59kB 7.28% ⚠️
cjs/index.cjs 4.99kB 22.39kB 28.66% ⚠️
index.legacy-esm.js 4.89kB 20.12kB 32.16% ⚠️
index.mjs 4.89kB 20.12kB 32.16% ⚠️
view changes for bundle: plugins/check-path/core

Assets Changed:

Asset Name Size Change Total Size Change (%)
CheckPathPlugin.native.js 20.76kB 413.08kB 5.29% ⚠️
view changes for bundle: react/subscribe

Assets Changed:

Asset Name Size Change Total Size Change (%)
cjs/index.cjs 739 bytes 5.74kB 14.77% ⚠️
index.legacy-esm.js 652 bytes 3.97kB 19.66% ⚠️
index.mjs 652 bytes 3.97kB 19.66% ⚠️
view changes for bundle: react/player

Assets Changed:

Asset Name Size Change Total Size Change (%)
cjs/index.cjs 3.6kB 30.36kB 13.43% ⚠️
index.legacy-esm.js 3.31kB 26.69kB 14.14% ⚠️
index.mjs 3.31kB 26.69kB 14.14% ⚠️

Comment thread core/player/src/controllers/error/controller.ts Outdated
Comment thread core/player/src/controllers/error/controller.ts Outdated
cehan-Chloe and others added 11 commits April 20, 2026 09:31
* error controller navigation
* Error controller expose to iOS/Android
* add asset error recovery via asyncNodePlugin on web and android

* fix test errors

* fix async test

* comment last broken test for now

* finish ios implementation of error recovery

* add errors with metadata to error controller on react and android

* re-enable react player test. fail player state from error controller if no transition available.

* update ResolverStage to be an enum

* fix android build errors

* finish ios error recovery implementation

* format kt and add ts tests

* fix mock package build

* fix throwable serializer. Improve react state management during errors

* remove throwing asset. fix error severity in jvm

* revert delete of one jvm test. use local data model in error middleware. fix ios tests

* revert change to player config. fix swift errorcontroller tests

* fix swiftlint error

* Update core/player/src/controllers/error/utils/isErrorWithMetadata.ts

Co-authored-by: Ketan Reddy <KetanReddy@users.noreply.github.com>

* Update plugins/async-node/core/src/utils/getNodeFromError.ts

Co-authored-by: Ketan Reddy <KetanReddy@users.noreply.github.com>

* Update core/player/src/controllers/error/utils/__tests__/isErrorWithMetadata.test.ts

Co-authored-by: Ketan Reddy <KetanReddy@users.noreply.github.com>

* make resolvererror public in player core

* update reference asset plugin tests

* update error middleware to export binding prefix

* add tests for useSubscriber hook

* fix eslint error

* update testing for async node plugin. fix issue with recursive search of async nodes on error

* add react player tests for error handling

* add error tests for resolver changes

* fix test and lint errors

* update lockfile

* add additional throwable serializer tests for new functionality

* replace hasErrorTransition function with getErrorTransitionState reused across the flow instance and error controller

* update error docs for async node plugin

* format kt files to fix lint issues

* ignore jvm testutils in codecov report

* separate JSError class in kt and code cleanup

* fix hermes ThrowablSserializerTest

* fix  type name in heremes ThrowableSerializerTest

* make JSErrorException constructor internal. use mapserializer in throwableserializer

* update JSValueError to serialize to and deserialize from JS objects

* code cleanup on JSValueError

* start replacing PlayerError type with real error

* fix j2v8 toInvokable. match error serialization to core changes on swift/kotlin

* kt lint format and fix swiftuiplayer test compile

* update const string enums in ios. clean up logging in error controller core

* fix test errors

* remove hasMetadata from ErrorWithMetadata. make JSKeys an enum with string constants

* cleanup kotlin implementation

* change enum namespaces for constants to structs

* remove encodable from HookWithResult generic

---------

Co-authored-by: Ketan Reddy <KetanReddy@users.noreply.github.com>
Comment thread ios/core/Sources/utilities/JSUtilities.swift
Comment thread ios/core/Sources/utilities/JSUtilities.swift Outdated
Comment thread ios/core/Sources/utilities/JSValue+Extensions.swift
Comment thread ios/core/Sources/utilities/JSValue+Extensions.swift Outdated
Comment thread ios/core/Sources/utilities/JSValue+Extensions.swift Outdated
Comment thread ios/core/Sources/utilities/JSValue+Extensions.swift Outdated
Comment thread ios/core/Sources/Types/Core/ErrorController.swift Outdated
Comment thread ios/core/Sources/Types/Core/ErrorController.swift Outdated
Comment thread react/player/src/asset/index.tsx Outdated
);

// Reset mock to track only clearErrors call
vitest.clearAllMocks();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we make this more specific instead of the root vitest for all of these?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

thanks. updated

@cehan-Chloe cehan-Chloe merged commit 8f3e550 into player-1-dot-zero May 6, 2026
14 checks passed
@cehan-Chloe cehan-Chloe deleted the error-controller branch May 6, 2026 17:31
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.

7 participants