Skip to content

[BUG] signUpWithPassword crashes on resolve: returns a LinkedHashMap instead of a WritableMap #23

Description

@esaugomez31

Describe the bug

On Android, signUpWithPassword crashes the app when the promise resolves (right after the credential is saved). The native module builds its success response with mapOf(...), which is a java.util.LinkedHashMap. The promise-resolve converter Arguments.fromJavaArgs only accepts WritableNativeMap/WritableNativeArray and primitives, so promise.resolve(...) throws. The credential save itself succeeds — only returning the result crashes. The sibling methods (signIn, createPasskey) already build their response with Arguments.createMap(), so only signUpWithPassword is affected.

Environment

  • React Native version: 0.85.3 (New Architecture enabled)
  • Library version: 0.8.1 (same mapOf is on main)
  • Platform: Android
  • Device information:
    • iOS: N/A
    • Android: any device, the failing step is a JS-bridge type conversion, not device-, OS-, or Kotlin-version-specific

Steps to Reproduce

  1. On Android, call signUpWithPassword({ username, password }).
  2. Accept the system password-manager save dialog.
  3. The app crashes as the promise resolves.

Expected behavior

The promise resolves with the result and the app continues.

Actual behavior

The app crashes with:

java.lang.RuntimeException: Cannot convert argument of type class java.util.LinkedHashMap
    at com.facebook.react.bridge.Arguments.fromJavaArgs(Arguments.kt:159)
    at com.facebook.react.bridge.PromiseImpl.resolve(PromiseImpl.kt:29)
    at com.credentialsmanager.CredentialsManagerModule$signUpWithPassword$1.invokeSuspend(CredentialsManagerModule.kt:76)

Screenshots

N/A

Code snippet

await signUpWithPassword({ username: "user@example.com", password: "secret" })
// save succeeds, then the promise resolve crashes the app

The cause is in signUpWithPassword (both newarch and oldarch modules):

val result = mapOf("type" to "password", "username" to username, "success" to true)
promise.resolve(result) // LinkedHashMap is not a WritableNativeMap

Suggested fix — build a WritableMap, as signIn/createPasskey already do:

val result = Arguments.createMap().apply {
  putString("type", "password")
  putString("username", username)
  putBoolean("success", true)
}
promise.resolve(result)

Additional context

  • Physical device and emulator: the crash is in the JS bridge type conversion, so it is independent of device/emulator.
  • Latest version: yes, reproduced on 0.8.1 (latest published); the same mapOf is on main.
  • Arguments.fromJavaArgs matches arguments against an exact-class whitelist (null, Boolean, Int, Double, Float, String, WritableNativeMap, WritableNativeArray), throwing on anything else, so a raw LinkedHashMap always fails.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions