Summary
instawp wp <site> and instawp exec <site> hang indefinitely at "Resolving site…" on accounts where the active team has more than zero sites visible via instawp sites list. The root cause is in dist/lib/site-resolver.js line 25, which hardcodes per_page: 100 when listing sites. The InstaWP /api/v2/sites endpoint returns an empty data array for any per_page value above ~20, so the resolver receives 0 sites, finds no match for the user's identifier, and falls into a state where the spinner never resolves.
Environment
@instawp/cli version: 0.0.1-beta.1
- Node: v22.22.0
- Platform: Linux (also reproducible on macOS based on user reports)
- API endpoint:
https://app.instawp.io/api/v2
Reproduction
- Log in with a token whose active team contains real sites:
instawp login --token "$INSTAWP_TOKEN"
- Confirm sites are visible to the API at default pagination:
Returns the expected list.
3. Run any command that calls resolveSite:
instawp wp <site-name-or-id> --api option get siteurl
instawp exec <site-name-or-id> --api ls -la
The command hangs at "Resolving site…" indefinitely (eventually times out at the shell level).
Expected behaviour
resolveSite finds the identifier in the API response and returns the matching site object, allowing instawp wp / instawp exec to proceed.
Actual behaviour
resolveSite receives { data: [], meta: { last_page: 1 } } from the API and cannot match. The spinner never advances.
Root cause
dist/lib/site-resolver.js:25:
js
const res = await client.get('/sites', { params: { per_page: 100 } });
Confirmed via direct API testing:
per_page value | Sites returned
-- | --
20 (default) | 3–9 (actual count)
25 | 0
50 | 0
100 | 0
The /api/v2/sites endpoint has an undocumented hard cap (somewhere between 20 and 25) above which it returns an empty data array — possibly silently capping per_page to a smaller value internally and the cap doesn't match the requested page size, or rejecting the parameter without an error. Either way, the CLI relying on per_page: 100 is brittle.
This is technically an API bug (the endpoint should either honour the requested per_page or return an error), but the CLI can avoid it entirely by paginating with safe page sizes.
Suggested fix
Either:
A. Simple — change per_page: 100 to per_page: 20 in site-resolver.js:25. Most accounts have fewer than 20 sites, so a single call still works for the common case.
B. Robust — paginate using per_page: 20 and walk meta.last_page to fetch all pages, so the resolver works for accounts with 20+ sites:
js
async function fetchAllSites(client) {
const all = [];
let page = 1;
while (true) {
const res = await client.get('/sites', { params: { per_page: 20, page } });
const items = res.data?.data ?? [];
all.push(...items);
if (page >= (res.data?.meta?.last_page ?? page)) break;
page++;
}
return all;
}
Option B is what instawp sites list effectively already does at default pagination — applying the same approach in resolveSite keeps behaviour consistent.
Workaround (until fixed)
Call the API directly:
bash
curl -X POST \
-H "Authorization: Bearer $INSTAWP_TOKEN" \
-H "Content-Type: application/json" \
"https://app.instawp.io/api/v2/sites/<site_id>/run-cmd" \
-d '{"commands":["wp option get siteurl"],"timeout_seconds":25}'
Note: instawp sites list works because it uses the API's default pagination (per_page=20); only resolveSite is affected because of its hardcoded per_page=100.
Additional context (optional, can drop if too much)
Discovered while diagnosing a WP Mail SMTP migration issue on a freshly-migrated v3 site. Token was scoped to a team that had recently been emptied (sites moved to a new "V3" team via the v2→v3 migration tool). After switching the active team in the dashboard, instawp sites list started returning the V3 sites correctly, but instawp wp continued to hang — which is what surfaced this bug as separate from the v3 migration itself.
Summary
instawp wp <site>andinstawp exec <site>hang indefinitely at "Resolving site…" on accounts where the active team has more than zero sites visible viainstawp sites list. The root cause is indist/lib/site-resolver.jsline 25, which hardcodesper_page: 100when listing sites. The InstaWP/api/v2/sitesendpoint returns an emptydataarray for anyper_pagevalue above ~20, so the resolver receives 0 sites, finds no match for the user's identifier, and falls into a state where the spinner never resolves.Environment
@instawp/cliversion:0.0.1-beta.1https://app.instawp.io/api/v2Reproduction
Returns the expected list. 3. Run any command that calls
resolveSite:The command hangs at "Resolving site…" indefinitely (eventually times out at the shell level).
Expected behaviour
resolveSitefinds the identifier in the API response and returns the matching site object, allowinginstawp wp/instawp execto proceed.Actual behaviour
resolveSitereceives{ data: [], meta: { last_page: 1 } }from the API and cannot match. The spinner never advances.Root cause
dist/lib/site-resolver.js:25:Confirmed via direct API testing:
The
/api/v2/sitesendpoint has an undocumented hard cap (somewhere between 20 and 25) above which it returns an emptydataarray — possibly silently cappingper_pageto a smaller value internally and the cap doesn't match the requested page size, or rejecting the parameter without an error. Either way, the CLI relying onper_page: 100is brittle.This is technically an API bug (the endpoint should either honour the requested
per_pageor return an error), but the CLI can avoid it entirely by paginating with safe page sizes.Suggested fix
Either:
A. Simple — change
per_page: 100toper_page: 20insite-resolver.js:25. Most accounts have fewer than 20 sites, so a single call still works for the common case.B. Robust — paginate using
per_page: 20and walkmeta.last_pageto fetch all pages, so the resolver works for accounts with 20+ sites:Option B is what
instawp sites listeffectively already does at default pagination — applying the same approach inresolveSitekeeps behaviour consistent.Workaround (until fixed)
Call the API directly:
Note:
instawp sites listworks because it uses the API's default pagination (per_page=20); onlyresolveSiteis affected because of its hardcodedper_page=100.Additional context (optional, can drop if too much)
Discovered while diagnosing a WP Mail SMTP migration issue on a freshly-migrated v3 site. Token was scoped to a team that had recently been emptied (sites moved to a new "V3" team via the v2→v3 migration tool). After switching the active team in the dashboard,
instawp sites liststarted returning the V3 sites correctly, butinstawp wpcontinued to hang — which is what surfaced this bug as separate from the v3 migration itself.