Skip to content

fix(core): contextualize runtime function loader failures - #45

Open
huytdps13400 wants to merge 1 commit into
margelo:mainfrom
huytdps13400:fix/43-runtime-function-load-errors
Open

fix(core): contextualize runtime function loader failures#45
huytdps13400 wants to merge 1 commit into
margelo:mainfrom
huytdps13400:fix/43-runtime-function-load-errors

Conversation

@huytdps13400

Copy link
Copy Markdown

Summary

  • wrap thrown runtime-function loader errors as RuntimeFunctionLoadError
  • include the function id, actual runtime name, and original cause message before runner serialization
  • preserve the original error as a non-enumerable cause locally
  • reject non-function loader results before caching them
  • explain likely module-initialization or missing native-package failures
  • preserve successful loading, caching, and runtime-function invocation behavior

The registered loader is wrapped before it is handed to the JSI registry, while the JS fallback validates before updating its runtime-local cache. Function-body errors remain outside the loader wrapper and keep their existing behavior.

Regression coverage

The new callable-module boundary test covers:

  • a loader that throws
  • loaders that resolve to undefined or an object
  • caller-visible serialized function/runtime context
  • local Error.cause
  • retry after an invalid result, proving the invalid value was not cached

RED before the implementation: 4/4 regression tests failed with the existing plain Error/TypeError behavior. A separate mutation check removed the cause attachment and failed specifically on the missing-cause assertion.

Verification

Passed locally:

  • frozen dependency installation
  • focused regression Jest: 4/4
  • runnable plain-JS/regression suites: 3 suites, 10/10 tests
  • packages/core TypeScript/plugin build
  • packages/state TypeScript build
  • example tsc --noEmit
  • changed-test ESLint
  • changed-test Prettier check
  • git diff --check

Repository-wide baseline limitations:

  • full plain Jest still fails in untouched App.test.tsx because the native NitroModules TurboModule is unavailable outside a built app; the other three suites pass
  • full example lint still reports existing errors in untouched legacy tests; the new test lints cleanly
  • the real Hermes/JSI path was simulated through the existing JSI globals and callable-module boundary; no device build was required for this JS-boundary fix

Supersedes #44, which GitHub closed automatically when its head branch was renamed.

Fixes #43

Wrap registered runtime-function loaders at the JS boundary and validate results before caching.

Report RuntimeFunctionLoadError with function and runtime context, retain the original cause locally, and include its message in serialized errors. Explain non-function results with initialization and missing native-package guidance.

Add callable-module regression coverage for thrown, undefined, object, and invalid-cache loader results.

Fixes margelo#43
@vercel

vercel Bot commented Aug 22, 2026

Copy link
Copy Markdown

@huytdps13400 is attempting to deploy a commit to the Margelo Team on Vercel.

A member of the Team first needs to authorize it.

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.

Runtime function whose module fails to initialize reports "Cannot read property 'X' of undefined" instead of the real cause

1 participant