Skip to content

v6.1.2

Choose a tag to compare

@mCodex mCodex released this 29 Apr 13:06
· 9 commits to master since this release

🚀 v6.1.2

A focused patch release that unblocks Re.Pack / rspack consumers, hardens the new cause property to fully match native ES2022 Error semantics, and ships a few CI hygiene fixes. No breaking changes — drop-in upgrade. 🎉


🐛 Bug Fixes

📦 Re.Pack / rspack: Cannot find module 'react-native-sensitive-info/hooks' (and /errors)

Consumers using Re.Pack / rspack (instead of Metro) were hitting:

[runtime not ready]: Error: Cannot find module 'react-native-sensitive-info/hooks'
  __rspack_missing_module
  ./src/hooks/useAppInitializer.tsx

🔍 Root cause: the subpath exports in package.json declared a "react-native" condition that pointed at raw TypeScript source (./src/hooks/index.ts). Metro transpiles node_modules so it worked there, but Re.Pack / rspack don't transpile library source by default, so resolution failed at bundle time.

✅ Removed the "react-native" condition from the ./, ./hooks, and ./errors subpath exports — now matching the convention used by react-native-mmkv, react-native-reanimated, and @react-native-async-storage/async-storage. The top-level "react-native": "src/index" and "source": "src/index" fields are kept so Metro still gets source-map debugging for the main entry.

📂 Changed: package.json


🔒 Error API: full ES2022 cause parity

Building on the type-compatibility fix from v6.1.1, this release polishes SensitiveInfoError and HookError so their cause property is indistinguishable from a native ES2022 Error.

cause is now non-enumerable

Previously assigned as a regular property (which would have made it enumerable, surface in Object.keys, and leak into JSON.stringify). Now installed via Object.defineProperty(this, 'cause', { writable: true, configurable: true, enumerable: false, ... }) — exactly how the native Error constructor does it.

✅ Logging, serialization, and DevTools error overlays no longer accidentally include the cause chain.

🧬 { cause: undefined } is now honored

Native new Error(msg, { cause: undefined }) still installs an own (non-enumerable) cause property. Both error classes now mirror that:

  • SensitiveInfoError already used 'cause' in options
  • HookError was checking cause !== undefined, which silently dropped the property — now also uses 'cause' in options

🏷️ Type-only cause declaration for older TS targets

Added declare readonly cause?: unknown on both classes so consumers compiling with a tsconfig lib that predates ES2022 can still reference err.cause without TS errors. The declare form is fully erasable — no class field is emitted, so it can't accidentally become an enumerable own property.

📂 Changed: src/errors.ts, src/hooks/types.ts


🧪 Tests

Added thorough coverage in src/tests/errors.test.ts and src/tests/hooks.types.test.ts:

  • cause is retained on the constructed error
  • cause is non-enumerable (descriptor check, hidden from Object.keys, hidden from JSON.stringify)
  • cause is not defined when no options are provided
  • cause is defined as undefined when explicitly passed ({ cause: undefined }) — matching native Error
  • cause propagates through subclasses (NotFoundError, etc.)

48 tests, all green. 💚


🛠️ Other Changes

🌿 CI workflow triggers aligned with the default branch

The repo's default branch is master, but test.yml, ios-build.yml, and android-build.yml were filtering push events on main, so those workflows weren't running on push to the actual default branch.

✅ Updated all three workflows to trigger on master.

📂 Changed: .github/workflows/test.yml, .github/workflows/ios-build.yml, .github/workflows/android-build.yml


⬆️ Upgrade

No code changes required — just bump:

yarn add react-native-sensitive-info@6.1.2
# or
npm install react-native-sensitive-info@6.1.2

If you're using Re.Pack / rspack and were stuck on a workaround for the Cannot find module 'react-native-sensitive-info/hooks' error, you can now remove that workaround.