ac4af582301a4e8a29245dbba767eba31334ddf9
2
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
e0eb74987c |
plugins: a dist branch not read is unknown, not "not on npm", and its read isn't cut off by one ask
ferock on Discord (v0.1.2399): the Plugins page showed the Chat page plugin (@magpie-community/page-chat, on the community repo's dist branch only, never on npm) as Coming soon. Cause: Info asks each package under npmEach (6s). npm said 404, and npmAsk turned to distInfo -> distPkg, which read the ~1.6MB index.json (GitHub and the jsDelivr mirror) under that same 6s context, holding distMu. On a slow link the read was cut off, distPkg returned nil as if the branch had no such package, and npmInfo kept "not on npm" (ok=true, empty NPM) for an hour, saved to plugin-npm.json. distWait then held a new read back for a minute. Fix: - distPkg returns (*distPackage, error): nil, nil only when the branch was read and lacks the package (or it is out of scope); an error wrapping errDistUnread when the branch couldn't be read (last read failed or not finished) and the kept index doesn't have it. - The index is read in its own goroutine (readDist), apart from the asker's context, with its own distReadFor (2m). One read at a time (distReading); askers wait for it or their own ctx, distMu is not held across the network read. A read that ends after its asker stopped waiting is kept for the next ask. - npmAsk: npm's errNotFound with the dist branch unknown becomes the dist error, so every caller that keeps "missing" (Info/npmInfo, newestOf in store.go, the update checks in updates.go) treats it as unknown and asks again. Readme says the branch couldn't be read instead of npm's not found. installDist returns the unread error rather than "has no". - mendDist was checked: it reads only local files, no dist read. Old data: a "not on npm" already kept in plugin-npm.json by an older build is asked again once it is an hour old, as before. Tests: TestDistReadSlowerThanAnAskIsntMissing (index.json held past npmEach: not kept as missing, and the next Info after the read ends has 0.1.7) and TestDistReadFailedIsntMissing (index.json 503: unknown, asked again; a read branch without the package is still errNotFound). fakeDist's reset waits for a read under way (distSettled). Run (mote-run; vet at base |
||
|
|
c48fccfad7 |
plugin: the dist index is read from GitHub beside jsDelivr's copy, so a plugin npm doesn't have is offered its newer version
star21321321124 on Discord: CodeArts 0.2.3 showed "已自动更新", the page said
every plugin was up to date, and Update did nothing, with 0.2.4 on the
plugins repo's dist branch. npm has neither CodeArts nor River (E404), so
npmAsk's version is the dist index's latest. With the 「国内镜像」 switch on,
index.json was read from jsDelivr first, and a 200 from it was final. A
jsDelivr edge serves the branch as it was when it cached it (s-maxage=43200):
on 10-28 gcore.jsdelivr.net served the index with codearts latest 0.2.3
(age 6631s) while raw.githubusercontent.com, cdn and fastly had 0.2.4. So
the hourly update, Check for updates and Update all saw 0.2.3.
readDistIndex now asks raw.githubusercontent.com beside the mirror (with
the switch on) and merges the two copies: every version either names,
each package's newer latest. Each version keeps the sha512 its own copy of
the branch names, which installDist checks the tarball against as before.
GitHub is waited for 5s (distGrace) past the mirror's answer; unreachable,
the mirror's copy is read alone, as before. Switch off: one read, as before.
River: on dist at 0.1.0 only, nothing newer; the test holds it "current".
Run (mote, at this tree rebased on
|