fix: add transform timeout for background decoding#2530
Conversation
|
|
The timeout added here is Dio-specific: Wrapping This does not add a default timeout. It only applies when |
What I don't understand is why we are expecting that some isolates will never return. That doesn't make sense and sounds like a Dart bug. |
I see it differently. The timeout is not because we expect isolates to normally never return, or because we are working around a Dart isolate bug. It is a defensive bound around an async operation. A Future is also allowed to never complete if the underlying work hangs, loops forever, waits on something that never responds, or gets stuck in a native/platform call. Awaiting it does not block the event loop, but the caller's async flow can still remain pending forever. Isolates give us concurrency and memory isolation, but they do not guarantee task completion. If the isolate workload or message path gets stuck, the caller still needs a bounded failure mode. A timeout gives us that instead of letting the request hang indefinitely. |
|
I agreed with your point, though it might be better if we introduce a new type of error like |
Updated. I added a separate
|
Thanks for pointing this out. I added tests for the new |
Code Coverage Report: Only Changed Files listed
Minimum allowed coverage is |
Fixes background JSON decoding hanging indefinitely by adding a dedicated
transformTimeoutoption.The timeout is independent from
receiveTimeout, so existing receive timeout semantics stay focused on network receive timing. By defaulttransformTimeoutisnull, which means no transform timeout limit and preserves existing behavior unless users opt in.New Pull Request Checklist
mainbranch to avoid conflicts (via merge from master or rebase)CHANGELOG.mdin the corresponding packageAdditional context and info (if any)
This adds:
RequestOptions.transformTimeoutOptions.transformTimeoutBaseOptions.transformTimeoutDioExceptionType.transformTimeoutWhen
transformTimeoutis set and response transformation exceeds the duration, Dio throwsDioExceptionType.transformTimeout.Existing users that do not set
transformTimeoutare unaffected.receiveTimeoutcontinues to represent receiving response bytes/chunk timing and is no longer used to limit background JSON transformation.Verified with:
dart analyze --fatal-infosindiodart analyze --fatal-infosinplugins/web_adapterdart test --chain-stack-tracesindio