feat(repo): add Octokit request timeouts and retry UI
Before, every GitHub call awaited indefinitely with no AbortSignal, so a "lie-fi" connection (technically online, effectively dead) left FluxNote stuck on the skeleton loader and the freshness badge spinning forever. Inject an 8s AbortSignal.timeout via octokit.hook.before (20s override on the recursive tree fetch), classify failures in the userRepo store as auth vs network, and surface a "Couldn't reach GitHub" retry button when no cached content is available.
This commit is contained in:
@@ -2,10 +2,21 @@ import { Octokit } from "@octokit/rest"
|
||||
|
||||
import { getAccessToken } from "@/modules/user/service/signIn"
|
||||
|
||||
export const DEFAULT_OCTOKIT_TIMEOUT_MS = 8_000
|
||||
|
||||
export const getOctokit = async (): Promise<Octokit> => {
|
||||
const response = await getAccessToken()
|
||||
|
||||
return new Octokit({
|
||||
const octokit = new Octokit({
|
||||
auth: response?.token ?? ""
|
||||
})
|
||||
|
||||
octokit.hook.before("request", (options) => {
|
||||
options.request ??= {}
|
||||
if (!options.request.signal) {
|
||||
options.request.signal = AbortSignal.timeout(DEFAULT_OCTOKIT_TIMEOUT_MS)
|
||||
}
|
||||
})
|
||||
|
||||
return octokit
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user