Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wasm throws exceptions using koin on IPv4 [_this.randomUUID is not a function] #2024

Closed
crowforkotlin opened this issue Oct 12, 2024 · 3 comments
Milestone

Comments

@crowforkotlin
Copy link

crowforkotlin commented Oct 12, 2024

ERROR
_this.randomUUID is not a function
TypeError: _this.randomUUID is not a function
    at kotlin.uuid.randomUUID_$external_fun (webpack-internal:///./kotlin/ComposeApp.uninstantiated.mjs:182:69)
    at <MordecaiX:composeApp>.kotlin.uuid.randomUUID_$external_fun__externalAdapter (http://192.168.1.127:8080/ComposeApp.wasm:wasm-function[13386]:0x48c6ec)
    at <MordecaiX:composeApp>.kotlin.uuid.secureRandomUuid (http://192.168.1.127:8080/ComposeApp.wasm:wasm-function[13384]:0x48c6bf)
    at <MordecaiX:composeApp>.kotlin.uuid.Companion.random (http://192.168.1.127:8080/ComposeApp.wasm:wasm-function[11818]:0x47d234)
    at <MordecaiX:composeApp>.org.koin.mp.generateId (http://192.168.1.127:8080/ComposeApp.wasm:wasm-function[63113]:0x8d55a6)
    at <MordecaiX:composeApp>.org.koin.core.module.Module.<init> (http://192.168.1.127:8080/ComposeApp.wasm:wasm-function[62929]:0x8d0f13)
    at <MordecaiX:composeApp>.org.koin.dsl.module (http://192.168.1.127:8080/ComposeApp.wasm:wasm-function[63094]:0x8d52d2)
    at <MordecaiX:composeApp>.org.koin.dsl.module$default (http://192.168.1.127:8080/ComposeApp.wasm:wasm-function[63095]:0x8d531c)
    at <MordecaiX:composeApp>.com.crow.mordecaix.model.di.<init properties ViewModelModule.kt> (http://192.168.1.127:8080/ComposeApp.wasm:wasm-function[68699]:0x94bde0)
    at <MordecaiX:composeApp>.com.crow.mordecaix.model.di.<get-viewmodelModule> (http://192.168.1.127:8080/ComposeApp.wasm:wasm-function[68690]:0x94bbcf)
commonMain.dependencies {
            implementation(compose.runtime)
            implementation(compose.foundation)
            implementation(compose.material)
            implementation(compose.material3)
            implementation(compose.ui)
            implementation(compose.components.resources)
            implementation(compose.components.uiToolingPreview)


            implementation(libs.jetbrains.kotlinx.coroutines)
            implementation(libs.jetbrains.kotlinx.collections)
            implementation(libs.jetbrains.lifecycle.viewmodel)
            implementation(libs.jetbrains.lifecycle.runtime.compose)
            implementation(libs.jetbrains.compose.materialWindow)
            implementation(libs.jetbrains.compose.material3.adaptive)
            implementation(libs.jetbrains.compose.material3.adaptive.layout)
            implementation(libs.jetbrains.compose.material3.adaptive.navigation)
            implementation(libs.jetbrains.androidx.navigation)
            implementation(libs.koin.core)
            implementation(libs.koin.compose)
            implementation(libs.koin.compose.viewmodel)
            implementation(libs.koin.compose.viewmodel.navigation)
            implementation(libs.ktor.client.core)

            implementation(libs.kotlinx.datetime)
        }
wasmJs {
        moduleName = "ComposeApp"
        browser {
            val projectDirPath = project.projectDir.path
            commonWebpackConfig {
                outputFileName = "composeApp.js"
                devServer = (devServer ?: KotlinWebpackConfig.DevServer()).apply {
                    static = (static ?: mutableListOf()).apply {
                        // Serve sources to debug inside browser
                        add(projectDirPath)
                    }
                }
            }
        }
        binaries.executable()
    }
compose-plugin = "1.7.0-rc01"
kotlin = "2.0.20"
koin = "4.0.0"

// ============================================
@OptIn(ExperimentalComposeUiApi::class)
fun main() {
    initializeApplication()
    ComposeViewport(document.body!!) {
        App()
    }
}
@Composable
fun App() {
    MordecaiXTheme {
        MordecaiXApp()
    }
}
@Composable
fun MordecaiXApp() { }
// ============================================

fun initializeApplication() {
    startKoin {
        modules(
            viewmodelModule, 
        )
    }
}

val viewmodelModule = module {
    viewModel { AppViewModel() }
}
class AppViewModel : ViewModel() {}
// ============================================

./gradlew wasmJsBrowerRun
It's normal to use localhost access

startkoin is normal, it is also normal when I delete modules, and there is a problem when modules are added

@crowforkotlin crowforkotlin changed the title wasm throws exceptions using koin on IPv4 wasm throws exceptions using koin on IPv4 [_this.randomUUID is not a function] Oct 12, 2024
@crowforkotlin crowforkotlin changed the title wasm throws exceptions using koin on IPv4 [_this.randomUUID is not a function] Wasm throws exceptions using koin on IPv4 [_this.randomUUID is not a function] Oct 12, 2024
kdroidFilter added a commit to kdroidFilter/koin that referenced this issue Nov 4, 2024
…g the benasher44/uuid library to generate UUIDs for WebAssembly targets.
kdroidFilter added a commit to kdroidFilter/koin that referenced this issue Nov 4, 2024
…g the benasher44/uuid library to generate UUIDs for WebAssembly targets.
kdroidFilter added a commit to kdroidFilter/koin that referenced this issue Nov 4, 2024
…g the benasher44/uuid library to generate UUIDs for WebAssembly targets.
kdroidFilter added a commit to kdroidFilter/koin that referenced this issue Nov 4, 2024
…g the benasher44/uuid library to generate UUIDs for WebAssembly targets.
kdroidFilter added a commit to kdroidFilter/koin that referenced this issue Nov 4, 2024
…g the benasher44/uuid library to generate UUIDs for WebAssembly targets.
kdroidFilter added a commit to kdroidFilter/koin that referenced this issue Nov 4, 2024
…g the benasher44/uuid library to generate UUIDs for WebAssembly targets.
kdroidFilter added a commit to kdroidFilter/koin that referenced this issue Nov 4, 2024
…g the benasher44/uuid library to generate UUIDs for WebAssembly targets.
kdroidFilter added a commit to kdroidFilter/koin that referenced this issue Nov 4, 2024
…g the benasher44/uuid library to generate UUIDs for WebAssembly targets.
@artemyto
Copy link

It seems like the problem is in this line:

fun KoinPlatformTools.generateId() : String = Uuid.random().toString()

Introduced in this commit: 926a7b6

Something is wrong with Uuid.random() on wasmJs

@artemyto
Copy link

It seems like it is required to use https or localhost to access Uuid.random() on wasmJs: https://stackoverflow.com/a/77981051

arnaudgiuliani added a commit that referenced this issue Nov 15, 2024
@arnaudgiuliani
Copy link
Member

4.0.1 will fix it 👍

@arnaudgiuliani arnaudgiuliani added this to the 4.0.1 milestone Nov 15, 2024
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

No branches or pull requests

3 participants