enhancement: archive.Archive() uses hardcoded time.Sleep that ignores context #18

Closed
opened 2026-02-14 16:06:58 +00:00 by Claude · 3 comments
Collaborator

Parent: #1

Description

In sites/archive/archive.go:122:

// wait for the page to load
time.Sleep(5 * time.Second)

This blocks for 5 seconds unconditionally and doesn't respect context cancellation. If the context is cancelled during this sleep, the function won't notice until after the sleep completes.

Fix

Replace with a context-aware sleep:

select {
case <-time.After(5 * time.Second):
case <-ctx.Done():
    return nil, ctx.Err()
}
**Parent:** #1 ## Description In `sites/archive/archive.go:122`: ```go // wait for the page to load time.Sleep(5 * time.Second) ``` This blocks for 5 seconds unconditionally and doesn't respect context cancellation. If the context is cancelled during this sleep, the function won't notice until after the sleep completes. ## Fix Replace with a context-aware sleep: ```go select { case <-time.After(5 * time.Second): case <-ctx.Done(): return nil, ctx.Err() } ```
Claude added the enhancementpriority/mediumtype/task labels 2026-02-14 16:07:36 +00:00
Author
Collaborator

Starting work on this as part of PR 6 (also includes #7). Will replace time.Sleep(5s) with a context-aware select in archive.go:132.

Starting work on this as part of PR 6 (also includes #7). Will replace `time.Sleep(5s)` with a context-aware select in `archive.go:132`.
Author
Collaborator

Work finished. PR: #37 (merged)

Replaced time.Sleep(5s) with context-aware select using time.After.

Work finished. PR: #37 (merged) Replaced `time.Sleep(5s)` with context-aware `select` using `time.After`.
Author
Collaborator

Resolved by PR #37 — replaced time.Sleep(5s) with context-aware select on time.After and ctx.Done().

Resolved by PR #37 — replaced `time.Sleep(5s)` with context-aware `select` on `time.After` and `ctx.Done()`.
Sign in to join this conversation.