Seeing a strange TypeError appear in the Browser c...
# coroutines
n
Seeing a strange TypeError appear in the Browser console that seems to be coming from the KotlinX Coroutines Core JS library:
Copy code
kotlinx-coroutines-core.js:19616 TypeError: Cannot read property 'iterator' of undefined
    at addAll (MutableCollections.kt:127)
    at GroupStatistics.mainLanguage_e0v785$ (_Arrays.kt:8034)
    at updateStatsLayout (main.kt:93)
    at Coroutine$processFetchedRepos$lambda.doResume (main.kt:85)
    at Coroutine$processFetchedRepos$lambda.CoroutineImpl.resumeWith_tl1gpc$ (CoroutineImpl.kt:47)
    at CancellableContinuationImpl.DispatchedTask.run (kotlinx-coroutines-core.js:2682)
    at WindowDispatcher$queue$ObjectLiteral.MessageQueue.process (kotlinx-coroutines-core.js:19877)
    at kotlinx-coroutines-core.js:19846
v
it could be a bug in the JS compiler, could you please make small self-contained example?
n
Not a trivial project, but it contains everything that is needed to reproduce the bug: https://gitlab.com/napperley/repo-stats
Will also need to include the prerequisite libraries from here: https://gitlab.com/webscene/webscene-core The libraries are created by running the following:
./gradlew publish
. After doing that some local Maven repos are created which are found in common/build/repository/org and js/build/repository/org. Copy the repos into
repos-stats/web-client/libs
. Do a Gradle refresh on repo-stats.
r
The problem is about wrong JSON parser, you are using
kotlin.js.JSON
expecting
kotlinx.serialization.json.JSON
. The proper fix would be like
Copy code
import kotlinx.serialization.json.JSON
// ...
val repos = JSON.parse(Repo.serializer().list, jsonStr)
👍 1