enhancement: staticCookieJar is not thread-safe #20
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Parent: #3
Description
staticCookieJarincookies_txt.gois a slice type withSet(),Delete(),Get(), andGetAll()methods that read and mutate the slice without synchronization.If a
CookieJaris shared between goroutines (e.g., multiple pages in the same browser context), concurrentSet()+Get()calls would cause data races.Current risk
Low — the current codebase doesn't appear to use the cookie jar concurrently. But as a public interface (
CookieJar), callers might use it in concurrent contexts.Fix
Add a
sync.RWMutextostaticCookieJar, or document that it's not safe for concurrent use. A wrapper typeSafeCookieJarcould be provided for thread-safe use.Starting work on this. Will wrap
staticCookieJarin a struct withsync.RWMutexfor thread safety.Work finished —
staticCookieJaris now a struct withsync.RWMutex. All reads useRLock, all writes useLock. Merged in PR #42.