zhudabao8433 on Discord (#general, 11-01): PowerContext
(@magpie-community/gateway-powercontext) could be installed yesterday and
today reads 即将上线 again.
Cause: PowerContext was never pulled. It is in registry.json since
plugins 1e4c8a2 (10-29) and on the dist branch (0.2.0, every dist commit
since), and not on npm (E404), so magpie learns its version from the
dist branch's ~1.7MB index.json. Coming soon is drawn whenever a listing
has an npm answer with no version, and three paths gave one without
anything confirming the package is missing:
- builds before v0.1.2413 kept a dist read cut off at npmEach (6s) as
"not on npm" in plugin-npm.json (ferock, e0eb74987). After an update,
InfoCached (the listings) and Info ("what it said last") still served
that empty answer while a new ask couldn't read the branch;
- the page turned every listing /api/plugins/npm said nothing of
(unknown: npm or the branch not read in time) into { weekly: 0 }, i.e.
Coming soon, and never asked again;
- /api/plugins/market gave every listing &NPM{} even when Info had no
answer for it.
Fix:
- market.go: a cached "not on npm" over an hour old is unknown
(npmEntry.missingStale): left out of InfoCached and of Info's seed.
One said within the hour stands, as before.
- plugins.js: a listing npm said nothing of is marked unknown ({ u: 1 }), which
offers Install (installDist waits for the branch with its own read);
the page asks again up to 4 times, 15s apart, and the answer replaces
it. A listing npm answered with no version still reads Coming soon.
- plugins.go: pluginMarketState leaves NPM nil when Info has no answer.
Old data: an old "not on npm" is unknown once an hour old, for every
user, with nothing to do on their side.
Tests:
- TestStaleMissingIsUnknownWhileDistUnread (internal/plugin): an
hours-old "not on npm" with the dist branch 503 is in neither
InfoCached nor Info; a minute-old one stands; once the branch answers,
Info has 0.2.0.
- plugin-npm-unknown.test.cjs: PowerContext with no npm answer shows
Install (enabled), Qoder answered without a version shows Coming soon,
and after the 15s re-ask (page.clock) PowerContext shows v0.2.0. en,
zh, zh-TW, ja, de; 980 and 420px; Chromium and WebKit.
Run (mote, at this commit rebased on origin/main 36af588e2):
- gofmt -l clean; go vet darwin, GOOS=windows, GOOS=linux -tags nogui on
./internal/plugin/... ./internal/gui/...: ok.
- go test -count=1 -timeout 45m ./internal/plugin/...: ok.
./internal/gui/...: TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and
TestMainWindowCorners/macOS_26_SDK (#3949) red, the same on an
origin/main 36af588e2 copy; TestCoreScriptBudget green (plugins.js is
1 byte under main's, a comment cut, no raise).
- node --test plugin-npm-unknown (22/22), plugin-market, i18n-keys: ok.
plugin-market webkit "the Plugins tab" was red once in the run after
the Go suite, its output lost; 3 of 3 green after, alone.
- Broken by hand: the Go test is red on origin/main's market.go (an
hours-old "not on npm" served; want it unknown); plugin-npm-unknown is
red (waits for Install) on origin/main's plugins.js.
- Earlier GUI batch (70 files: plugin*, market*, i18n*,
deprecation-notice, list-sort), before the rebase: 968/974; the reds
are plugin-move-unserved (#4410, #4392, red the same on main) and
plugin-github-filter chromium en 420px, batch only (#4679).
Not tried: a real slow network from China; zhudabao8433's version is not
known.
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 2cfb8351d, tests again at this commit rebased
on origin/main 484b45d82, which changed no Go in plugin or gui; pushed on 7dc8a18d0, which
touches only internal/provider and internal/gateway):
- gofmt -l: nothing
- go vet ./internal/plugin/..., GOOS=windows go vet ./...,
GOOS=linux go vet -tags nogui ./...: ok
- go test -count=1 -timeout 45m ./internal/plugin/... ./internal/gui/...:
internal/plugin ok (103.6s). internal/gui FAIL, two tests only, both
red the same on a fresh origin/main 484b45d82 run alone and filed:
TestSettingsSaveKeepsWhatItDoesNotSend (SearchAll, #4514) and
TestMainWindowCorners/macOS_26_SDK on mote's macOS 27 (#3949).
Broken by hand (mote-run, -run DistRead):
- npmAsk's errNotFound -> dist error override removed: both new tests
red (the market kept an empty entry).
- readDist given the asker's ctx (the old cut-off): the slow test red
(after the dist answered, still no version).
Not tried: a real slow link or ferock's machine; the real index.json
from the dist branch; the GUI page itself (actionFor already shows a
spinner for a package with no npm entry yet).