question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

-1 returned for status code when using await with coroutines

See original GitHub issue

Bug Report

Description

When my request is unsuccessful, and is awaited using the coroutine methods, the status code is being returned as -1

request.responseString().second.statusCode // RETURNS 401
request.awaitStringResponseResult().second.statusCode // RETURNS -1

Expected behavior

The correct status code should be returned when using coroutines. -1 is not a valid status code.

Development Machine

Complete the following information if applicable

  • OS: Windows 10
  • IDE: IntelliJ
  • Fuel version: 2.0.1
  • Kotlin version: 1.3.21
implementation group: 'org.jetbrains.kotlinx', name: 'kotlinx-coroutines-core', version: '1.1.1'
implementation 'com.github.kittinunf.fuel:fuel:2.0.1'
implementation 'com.github.kittinunf.fuel:fuel-coroutines:2.0.1'

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
thomhurstcommented, Feb 25, 2019

@SleeplessByte

com.github.kittinunf.fuel.core.BubbleFuelError: HTTP Exception 401 Unauthorized
Caused by: com.github.kittinunf.fuel.core.BubbleFuelError: HTTP Exception 401 Unauthorized
	com.github.kittinunf.fuel.core.FuelError$Companion.wrap(FuelError.kt:84)
	com.github.kittinunf.fuel.core.requests.SuspendableRequest.prepareResponse(SuspendableRequest.kt:34)
	com.github.kittinunf.fuel.core.requests.SuspendableRequest.awaitResult(SuspendableRequest.kt:43)
	com.github.kittinunf.fuel.core.DeserializableKt.awaitResponseResult(Deserializable.kt:250)
	models.KLoadRequest$execute$2$$special$$inlined$awaitStringResponseResult$1.invokeSuspend(Coroutines.kt:68)
	models.KLoadRequest$execute$2$$special$$inlined$awaitStringResponseResult$1.invoke(Coroutines.kt)
	kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:91)
	kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:146)
	kotlinx.coroutines.BuildersKt.withContext(Unknown Source)
	models.KLoadRequest$execute$2.invokeSuspend(KLoadRequest.kt:83)
	kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:32)
	kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:233)
	kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:594)
	kotlinx.coroutines.scheduling.CoroutineScheduler.access$runSafely(CoroutineScheduler.kt:60)
	kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:742)
Caused by: com.github.kittinunf.fuel.core.FuelError: HTTP Exception 401 Unauthorized
	com.github.kittinunf.fuel.core.FuelError$Companion.wrap(FuelError.kt:85)
Caused by: com.github.kittinunf.fuel.core.HttpException: HTTP Exception 401 Unauthorized
	com.github.kittinunf.fuel.core.requests.SuspendableRequest.prepareResponse(SuspendableRequest.kt:32)
	com.github.kittinunf.fuel.core.requests.SuspendableRequest.awaitResult(SuspendableRequest.kt:43)
	com.github.kittinunf.fuel.core.DeserializableKt.awaitResponseResult(Deserializable.kt:250)
	models.KLoadRequest$execute$2$$special$$inlined$awaitStringResponseResult$1.invokeSuspend(Coroutines.kt:68)
	models.KLoadRequest$execute$2$$special$$inlined$awaitStringResponseResult$1.invoke(Coroutines.kt)
	kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:91)
	kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:146)
	kotlinx.coroutines.BuildersKt.withContext(Unknown Source)
	models.KLoadRequest$execute$2.invokeSuspend(KLoadRequest.kt:83)
	kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:32)
	kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:233)
	kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:594)
	kotlinx.coroutines.scheduling.CoroutineScheduler.access$runSafely(CoroutineScheduler.kt:60)
	kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:742)



0reactions
kittinunfcommented, Feb 26, 2019

Thanks for your report!!! @thomhurst I will make sure that we have the next version sooner rather than rather.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Kotlin Coroutine returning after response.await()
I am trying to make an android app connecting to api, and for that I am using Kotlin Coroutines and Retrofit. I was...
Read more >
Kotlin Coroutines by Tutorials, Chapter 5: Async/Await
First, you've removed the callback from the parameters, and, secondly, you've returned a GlobalScope. async() block as the return value for the function....
Read more >
Async code using Kotlin Coroutines | by Fabio Collini
This syntax is valid but we are creating a new coroutines using async and immediately waiting for the result using await . There...
Read more >
Coroutines and Tasks — Python 3.11.1 documentation
Wrap the coro coroutine into a Task and schedule its execution. Return the Task object. If name is not None , it is...
Read more >
Async and Await - Kotlin Coroutines - YouTube
In this video you will learn what async and await can be used for in coroutines.⭐ Get certificates for your future job⭐ Save...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found