From f83be9e1b203d68001c6a36df4ada8a313411996 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Thu, 5 Mar 2026 17:55:20 +0000 Subject: [PATCH] docker serve: add timeout to volume restore so slow remotes don't block startup When restoring volumes from saved state during plugin startup, a slow or unreachable remote could block indefinitely in fs.NewFs. Add a 30-second per-volume timeout context so that individual volume failures are logged and skipped rather than blocking the entire plugin. --- cmd/serve/docker/driver.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/cmd/serve/docker/driver.go b/cmd/serve/docker/driver.go index 4cb8f31f2..ad0a420e8 100644 --- a/cmd/serve/docker/driver.go +++ b/cmd/serve/docker/driver.go @@ -21,6 +21,12 @@ import ( "github.com/rclone/rclone/vfs/vfscommon" ) +const ( + // volTimeout is the maximum time to wait for a single volume to + // be restored (filesystem setup) during plugin startup. + volTimeout = 30 * time.Second +) + // Driver implements docker driver api type Driver struct { root string @@ -356,7 +362,12 @@ func (drv *Driver) restoreState(ctx context.Context) error { } for _, vol := range state { - if err := vol.restoreState(ctx, drv); err != nil { + // Use a timeout so that a slow or unreachable remote does + // not block the plugin from starting up. + volCtx, cancel := context.WithTimeout(ctx, volTimeout) + err := vol.restoreState(volCtx, drv) + cancel() + if err != nil { fs.Logf(nil, "Failed to restore volume %q: %v", vol.Name, err) continue }