Skip to content

dropbox: backend SDK calls do not propagate caller cancellation #9688

Description

@MikeeI

Before you start

  • I have searched the forum and the existing issues and this hasn't already been requested.
  • I have checked the latest beta and this feature doesn't already exist.

Associated forum post URL

None. I searched the relevant forum discussions directly.

rclone version

rclone v1.75.0-beta.9999.17629d67b
- os/version: ubuntu 24.04 (64 bit)
- os/kernel: 6.8.0-107-generic (x86_64)
- os/type: linux
- os/arch: amd64
- go/version: go1.26.5
- go/linking: static
- go/tags: none

What problem are you trying to solve?

Summary

Dropbox backend operations receive a caller context.Context, but the backend stores the SDK's non-context client interfaces and calls their non-context methods. In the pinned SDK, those wrappers execute requests with context.Background(), so cancellation of the rclone caller context does not cancel an in-flight Dropbox request. This is source-proven; user-visible cancellation delay has not been reproduced.

Evidence

  • backend/dropbox/dropbox.go:383-400 stores files.Client, sharing.Client, users.Client, and team.Client, rather than their context-aware interfaces.
  • The backend calls non-context SDK methods throughout. For example, backend/dropbox/dropbox.go:2022-2024 calls UploadSessionStart, and backend/dropbox/dropbox.go:2055-2060 calls UploadSessionAppendV2, although uploadChunked has the caller context.
  • rclone pins github.com/dropbox/dropbox-sdk-go-unofficial/v6 v6.4.0. In that SDK, UploadSessionAppendV2 delegates to UploadSessionAppendV2Context(context.Background(), ...) (source); the SDK also exposes context-aware client interfaces and methods.
  • backend/dropbox/dropbox.go:448-475 checks the caller context during retry classification, which occurs only after the SDK call returns.
  • Closed tracker #3257 established the context-propagation goal, listed Dropbox as unfinished, and closed with the maintainer noting that remaining work should happen in backend-specific issues.

Impact

The absence of caller cancellation from the in-flight HTTP request is source-proven. The resulting shutdown delay, stalled-request duration, and transfer impact have not been measured. Batcher finalization has a separate lifecycle and is not part of this report.

Question

Would it make sense for caller-scoped Dropbox operations to use the SDK's context-aware interfaces and *Context methods, while preserving independently owned batch-finalization contexts?

I checked all relevant issues, comments, pull requests, and forum threads; this report is not a duplicate.

How do you think rclone should be changed to solve that?

Store the SDK's context-aware client interfaces and call the corresponding *Context methods with each operation's caller context. Keep batcher-owned contexts where work intentionally outlives an individual call.

Getting involved

  • I'm willing to help implement, test or fund this feature.

I am reporting this finding only and am not currently proposing a pull request.

Investigated extensively with GPT-5.6 Sol (xhigh reasoning effort), using Oh My Pi as the agent framework.

Activity

  1. ncw commented on Jul 30, 2026

    @ncw
    Member

    Confirmed against master - the backend stores the context-less SDK client interfaces and there are zero *Context calls anywhere in it, even though SDK v6 provides ContextClient / NewContext throughout. So Ctrl-C, rc job/stop, --max-duration etc. cannot abort an in-flight Dropbox request; rclone waits for it to finish or die by --timeout. This is a leftover from the #3257 context plumbing.

    The fix is mechanical but wide: switch the four stored client interfaces to the *Context variants and thread ctx through every call site, while deliberately keeping background-context lifetimes for the batcher commit and Shutdown paths. Large diff, easy review, low regression risk - help welcome.

  2. Milad93R commented on Jul 31, 2026

    @Milad93R

    I’d like to work on this. I confirmed that SDK v6.4.0 exposes the context-aware clients and matching *Context methods. I’ll keep the change scoped to propagating caller contexts, while preserving independently owned batch/finalization lifetimes as described, and add a cancellation regression test.

  3. lntutor commented on Jul 31, 2026

    @lntutor
    Contributor

    Hi @Milad93R — I independently investigated this issue and prepared a test-first implementation plan, but I saw your comment before starting any code changes. Are you actively working on a fix? I do not want to duplicate your effort. I am happy to step back if you are proceeding.

  4. added a commit that references this issue on Aug 1, 2026
    590e1e5
  5. added a commit that references this issue on Aug 2, 2026
    c97ab80
  6. added a commit that references this issue on Sep 4, 2026
    10eb7b5
  7. added a commit that references this issue on Oct 6, 2026
    da9fc51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions