Spinning up Playwright or Puppeteer to scrape modern React Router v7 / Remix SSR pages burns residential proxy bandwidth and container RAM—even though the entire page state is already embedded inside the initial HTML response.
When scraping directories like the Shopify Partners Directory, the server streams structured loader payloads into inline <script> blocks via window.__reactRouterContext.streamController.enqueue(...). Instead of standard nested JSON, React Router v7 encodes a pointer-indexed Turbo Stream array to avoid duplicating references.
Here is how we eliminated headless browsers and cut extraction latency down to seconds in TypeScript.
1. Decoding the Turbo Stream Pointer Graph
In a Turbo Stream array, object keys prefixed with _<index> point back to string keys in the flat array, and numeric values point to resolved values at those array indices. A naive recursive parser risks infinite loops on cyclic object references, so a cycle-safe Map<number, any> memo table is essential:
export function decodeTurboStream(arr: unknown[]): any {
if (!Array.isArray(arr) || arr.length === 0) return null;
const memo = new Map<number, any>();
function resolve(idx: number): any {
if (idx < 0 || idx >= arr.length) return null;
if (memo.has(idx)) return memo.get(idx);
const val = arr[idx];
if (val === null || typeof val !== 'object') return val;
if (Array.isArray(val)) {
const out: any[] = [];
memo.set(idx, out);
for (const item of val) {
out.push(typeof item === 'number' ? resolve(item) : item);
}
return out;
}
const out: Record<string, any> = {};
memo.set(idx, out);
for (const [k, vIdx] of Object.entries(val as Record<string, unknown>)) {
const keyIdx = k.startsWith('_') ? Number.parseInt(k.slice(1), 10) : Number.NaN;
const realKey = Number.isFinite(keyIdx) ? String(resolve(keyIdx)) : k;
out[realKey] = typeof vIdx === 'number' ? resolve(vIdx) : vIdx;
}
return out;
}
return resolve(0);
}
Once decoded, a plain got-scraping HTTP GET yields the complete agency payload (handle, tier, employeeCountRange, activeCollaborations, featuredClients, socials, website) in ~150ms without launching Chrome.
2. Graceful Pre-Timeout Checkpointing in Serverless Scrapers
Even fast HTTP scrapers can hit container run limits on huge multi-thousand-item enrichment jobs. If the runtime hard-kills your process, you lose your RUN_SUMMARY and cross-run deduplication state.
In our shared scraper toolkit (ResultSink), we parse APIFY_TIMEOUT_AT at startup and arm a graceful stop guard 25 seconds before the hard kill:
const rawTimeout = process.env.APIFY_TIMEOUT_AT || process.env.ACTOR_TIMEOUT_AT;
const parsedTimeout = rawTimeout ? Date.parse(rawTimeout) : Number.NaN;
this.deadlineMs =
Number.isFinite(parsedTimeout) && parsedTimeout - Date.now() > 35_000
? parsedTimeout - 25_000
: null;
Every concurrent worker checks sink.done before starting the next request, flushes the persistent Key-Value Store (onlyNewItems monitoring state), writes RUN_SUMMARY, and exits with status SUCCEEDED.
3. Open-Source n8n Workflows + Free 50-Row Sample CSV Datasets
We packaged 5 ready-to-import .n8n.json automation workflows (Slack alerts & Google Sheets CRM syncs) alongside free 50-row sample B2B datasets for Shopify Platinum/Premier agencies, Webflow Certified agencies, Stripe Partners, and US SLED Government RFPs:
- Interactive Hub & Downloads: Spotless Studios B2B Lead Datasets & n8n Workflows
- Open-Source GitHub Repo: GYYGUGUY/b2b-lead-datasets-and-n8n-workflows
- Live Scrapers on Apify: Shopify Partners Scraper v0.2 · SLED Government Bids Scraper
Top comments (0)