kidchen94 reported four ways the credits refresh failed on one machine:
Chrome's last-used profile decided whose session a read used, a page
Chrome translated could not be parsed, a JPY billing account timed out
on the wait for a "$" row, and an ambiguous billing account could only be
fixed with the machine-wide VERTEX_BILLING_ACCOUNT.
- Chrome profile: profileDirectories (Google account -> profile
directory), profileDirectory and VERTEX_CHROME_PROFILE_DIRECTORY pass
--profile-directory to every Chrome the plugin opens: reads, the
kept browser and the sign-in window. The name is checked (no path
separators, no "."/"..", no leading "-"), and a kept browser is never
handed to a read pinned to another directory.
- Billing account: billingAccounts maps a project to its billing
account, ahead of the row's billingAccount and the environment. The
discovery error names the project, the accounts the Console showed and
the option to set.
- Currency: billingCurrencies names a billing account's currency (USD,
JPY). Yen is read with no minor unit and shown as "¥8500 JPY". A ¥ is
never taken for yen on its own, since the Console writes yuan the same
way: a ¥ table read as USD names the setting at once. Amounts need
strict comma grouping. The row wait is any cell with a digit, not "$".
- Translation: a page Chrome marked translated (translated-ltr/rtl on
<html>) and a table with non-English column names each give an error
that says so and how to turn translation off, not a timeout or
"session may be expired".
- Cache: the profile directory and the currency map join the cache key
only when set, so existing caches are kept.
- fetch_credits.mjs takes --profile-directory and --currency.
Run at this head on mote (macOS, Node 22, Chrome for Testing 1234):
node --test test/*.test.mjs: 84 tests, 81 pass, 3 skipped (the
Linux/Windows-only ones, as on origin/main's 76), 0 fail.
bun scripts/check.mjs: ok.
Broken by hand: the new tests against origin/main's lib/ and index.mjs.
The JPY and translated browser tests fail with the reporter's symptom
(21s and 41s, "Credits table was not found or is empty; the session may
be expired"), the billing test with "set VERTEX_BILLING_ACCOUNT
explicitly", the profile test with "Chrome used Default, not Profile 1",
and plugin.test.mjs fails to load (billingCurrenciesOf is new).
Not tried: a real Console (a JPY billing account, a page Chrome
translated, a real multi-profile Chrome); the fixtures are tables
served from the test. Not run on Windows or Linux. Chrome's own
translate preference is not written; translation is detected, not
prevented. Currencies other than USD and JPY are refused, not
converted.