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

Unknown field type in Record: 'com.apollographql.apollo.api.json.JsonNumber' #26

Open
wiyarmir opened this issue Sep 4, 2024 · 2 comments

Comments

@wiyarmir
Copy link

wiyarmir commented Sep 4, 2024

I think #18 broke the cache. Updating to 0.0.4 gives this crash

FATAL EXCEPTION: main
Process: net.avianlabs.app.debug, PID: 30164
java.lang.IllegalStateException: Unknown field type in Record: 'com.apollographql.apollo.api.json.JsonNumber@33fcb91'
	at com.apollographql.apollo.cache.normalized.api.internal.RecordWeigher.weighField(RecordWeigher.kt:54)
	at com.apollographql.apollo.cache.normalized.api.internal.RecordWeigher.calculateBytes(RecordWeigher.kt:28)
	at com.apollographql.apollo.cache.normalized.api.Record.getSizeInBytes(Record.kt:47)
	at com.apollographql.apollo.cache.normalized.api.MemoryCache$CacheEntry.<init>(MemoryCache.kt:156)
	at com.apollographql.apollo.cache.normalized.api.MemoryCache.internalMerge(MemoryCache.kt:131)
	at com.apollographql.apollo.cache.normalized.api.MemoryCache.merge(MemoryCache.kt:117)
	at com.apollographql.apollo.cache.normalized.api.internal.OptimisticCache.merge(OptimisticCache.kt:38)
	at com.apollographql.apollo.cache.normalized.internal.DefaultApolloStore.writeOperationSync$lambda$7(DefaultApolloStore.kt:182)
	at com.apollographql.apollo.cache.normalized.internal.DefaultApolloStore.$r8$lambda$ht5x9IXcSXwVj2N9CMzMBBLIVgo(Unknown Source:0)
	at com.apollographql.apollo.cache.normalized.internal.DefaultApolloStore$$ExternalSyntheticLambda4.invoke(D8$$SyntheticClass:0)
	at com.apollographql.apollo.cache.normalized.internal.Lock.write(Lock.kt:18)
	at com.apollographql.apollo.cache.normalized.internal.DefaultApolloStore.writeOperationSync(DefaultApolloStore.kt:181)
	at com.apollographql.apollo.cache.normalized.internal.DefaultApolloStore.writeOperation(DefaultApolloStore.kt:160)
	at com.apollographql.apollo.cache.normalized.internal.ApolloCacheInterceptor$maybeWriteToCache$2.invokeSuspend(ApolloCacheInterceptor.kt:85)
	at com.apollographql.apollo.cache.normalized.internal.ApolloCacheInterceptor$maybeWriteToCache$2.invoke(Unknown Source:8)
	at com.apollographql.apollo.cache.normalized.internal.ApolloCacheInterceptor$maybeWriteToCache$2.invoke(Unknown Source:2)
	at com.apollographql.apollo.cache.normalized.internal.ApolloCacheInterceptor.maybeAsync(ApolloCacheInterceptor.kt:53)
	at com.apollographql.apollo.cache.normalized.internal.ApolloCacheInterceptor.maybeWriteToCache(ApolloCacheInterceptor.kt:76)
	at com.apollographql.apollo.cache.normalized.internal.ApolloCacheInterceptor.maybeWriteToCache$default(ApolloCacheInterceptor.kt:60)
	at com.apollographql.apollo.cache.normalized.internal.ApolloCacheInterceptor$readFromNetwork$1.invokeSuspend(ApolloCacheInterceptor.kt:265)
	at com.apollographql.apollo.cache.normalized.internal.ApolloCacheInterceptor$readFromNetwork$1.invoke(Unknown Source:8)
	at com.apollographql.apollo.cache.normalized.internal.ApolloCacheInterceptor$readFromNetwork$1.invoke(Unknown Source:4)
	at kotlinx.coroutines.flow.FlowKt__TransformKt$onEach$$inlined$unsafeTransform$1$2.emit(Emitters.kt:219)
	at kotlinx.coroutines.flow.internal.SafeCollectorKt$emitFun$1.invoke(SafeCollector.kt:11)
	at kotlinx.coroutines.flow.internal.SafeCollectorKt$emitFun$1.invoke(SafeCollector.kt:11)
	at kotlinx.coroutines.flow.internal.SafeCollector.emit(SafeCollector.kt:113)
	at kotlinx.coroutines.flow.internal.SafeCollector.emit(SafeCollector.kt:82)
	at com.apollographql.apollo.network.http.HttpNetworkTransport$execute$1$invokeSuspend$$inlined$map$1$2.emit(Emitters.kt:219)
	at kotlinx.coroutines.flow.FlowKt__BuildersKt$flowOf$$inlined$unsafeFlow$2.collect(SafeCollector.common.kt:112)
	at com.apollographql.apollo.network.http.HttpNetworkTransport$execute$1$invokeSuspend$$inlined$map$1.collect(SafeCollector.common.kt:112)
	at kotlinx.coroutines.flow.FlowKt__CollectKt.emitAll(Collect.kt:105)
	at kotlinx.coroutines.flow.FlowKt.emitAll(Unknown Source:1)
	at com.apollographql.apollo.network.http.HttpNetworkTransport$execute$1.invokeSuspend(HttpNetworkTransport.kt:75)
	at com.apollographql.apollo.network.http.HttpNetworkTransport$execute$1.invoke(Unknown Source:8)
	at com.apollographql.apollo.network.http.HttpNetworkTransport$execute$1.invoke(Unknown Source:4)
	at kotlinx.coroutines.flow.SafeFlow.collectSafely(Builders.kt:57)
	at kotlinx.coroutines.flow.AbstractFlow.collect(Flow.kt:226)
	at kotlinx.coroutines.flow.FlowKt__TransformKt$onEach$$inlined$unsafeTransform$1.collect(SafeCollector.common.kt:112)
	at com.apollographql.apollo.cache.normalized.internal.ApolloCacheInterceptor$readFromNetwork$$inlined$map$1.collect(SafeCollector.common.kt:112)
	at kotlinx.coroutines.flow.FlowKt__CollectKt.emitAll(Collect.kt:105)
	at kotlinx.coroutines.flow.FlowKt.emitAll(Unknown Source:1)
	at com.apollographql.apollo.cache.normalized.internal.ApolloCacheInterceptor$interceptQuery$1.invokeSuspend(ApolloCacheInterceptor.kt:200)
	at com.apollographql.apollo.cache.normalized.internal.ApolloCacheInterceptor$interceptQuery$1.invoke(Unknown Source:8)
	at com.apollographql.apollo.cache.normalized.internal.ApolloCacheInterceptor$interceptQuery$1.invoke(Unknown Source:4)
	at kotlinx.coroutines.flow.SafeFlow.collectSafely(Builders.kt:57)
	at kotlinx.coroutines.flow.AbstractFlow.collect(Flow.kt:226)
	at com.apollographql.apollo.ApolloClient$executeAsFlowInternal$flow$1$2.invokeSuspend(ApolloClient.kt:260)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
	at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:111)
	at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:99)
	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:811)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:715)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:702)
	Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@cf66393, Dispatchers.Main.immediate]
@martinbonnin
Copy link
Collaborator

Good catch. The "good" fix might be to support JsonNumber in RecordWeigher. I'll look into this.

In the meantime, feel free to stay on 0.0.3 (or define your own custom adapter)

@martinbonnin
Copy link
Collaborator

Pull request is here

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

2 participants