Fix multi-process crash and Safari userscript compatibility#38
Open
wozniakpawel wants to merge 8 commits intozelestcarlyone:masterfrom
Open
Fix multi-process crash and Safari userscript compatibility#38wozniakpawel wants to merge 8 commits intozelestcarlyone:masterfrom
wozniakpawel wants to merge 8 commits intozelestcarlyone:masterfrom
Conversation
stacks_worker is None in production mode, causing 'NoneType' object has no attribute 'downloader' when testing the fast download key.
Use fetch as primary request method with GM_xmlhttpRequest as fallback for environments without CORS. Fixes silent request failures in Safari's Userscripts extension.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
NAS Docker has DNS issues without host networking. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Patterns like config/ matched src/stacks/config/ too. Using /config only matches at the transfer root. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two bug fixes:
1. Fix
test_keyendpoint crash in multi-process modeapi_config_test_key()accessescurrent_app.stacks_worker.downloaderwithout checking ifstacks_workerisNone. In production (multi-process mode via gunicorn), the worker runs in a separate process andstacks_workeris set toNoneon the Flask app. This causes:whenever a user tests their Anna's Archive secret key in the settings UI. The fix adds a
Noneguard — the worker cache update is only relevant in debug/single-process mode anyway.2. Fix userscript silent failure on Safari (Userscripts extension)
Safari's Userscripts extension has a broken
GM_xmlhttpRequestimplementation — callbacks (onload,onerror,ontimeout) never fire, causing the script to hang silently. This means:fetchSubdirectories()never resolves, blockinginit()The fix changes
apiRequest()to usefetchas the primary request method and fall back toGM_xmlhttpRequestonly whenfetchfails (e.g. CORS not available). This works on both Safari and Chrome/Firefox:fetchworks when the server has CORS enabled (Flask-CORS is already included)fetchworks with CORS, or falls back toGM_xmlhttpRequestfor cross-origin requests without CORSNote: for Safari users connecting to a remote server over HTTPS (e.g. via a Caddy reverse proxy), the server's CORS headers from Flask-CORS are sufficient — no additional CORS configuration is needed on the proxy.