fix(forge): one process renews the git sign-in at a time, so renewals at once no longer lose it #140
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/upscaling
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
testing wanted
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!140
Loading…
Reference in a new issue
No description provided.
Delete branch "HumanBean/Longshot:fix/forge-session-lock"
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?
Why
Twice today the git.magicbean.dev sign-in was lost mid-work ("token was already used"): git's credential helper and forge.py, or two agents, renewed the expired token at the same moment, Forgejo takes each refresh token once, and the second renewal threw the sign-in away. Everyone then had to sign in again.
What changed
scripts/magicbean_login.py:forge_session()renews under a lock (forge.json.lock,flockon Linux,msvcrt.lockingon Windows) and reads the saved sign-in again once it holds it, so a process that waited uses the token the first one saved instead of renewing with a spent refresh token. A token still good returns at once, without the lock.forge_expire()takes the lock too.write_private()writes to a temporary file named with the process id, so two writers never share one.tests/test_forge_session_lock.py: 4 processes renew an expired sign-in together against a stand-in for Forgejo that refuses a reused refresh token.Flags and settings
None
Measurements
main:
a7aa850b(2026-11-13)this PR: fix/forge-session-lock @
795d16b3a7aa850b795d16b3Testing
Tested: the new test on Linux (fails on main's code, passes here);
tests/test_forge_pr.py.Not tested: the Windows lock (
msvcrt.locking) on Windows.Needs other testers: Windows: run
python -I scripts/forge.py whoamitwice at once after the token expired (an hour after sign-in); both should answer (request to open).Screenshots
Nothing on screen
Risk and rollback
A process holding the lock while Forgejo is slow makes others wait for it (the request has a timeout). Reverting the commit is enough.
Checklist
For everyone
type(scope): description).main.python -I -B tests/run_all.pyrun and passing (any failure that also fails onmainis named above).third_party/untouched (a new folder with aPROVENANCE.mdinstead).