@nitpicker/crawler 0.25.0 → 0.25.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # @nitpicker/crawler
2
2
 
3
- ヘッドレスブラウザでWebサイトをクロールし、`.nitpicker` アーカイブを生成・更新する内部パッケージです。アーカイブ自体の読み書き(スキーマ・マイグレーション・concat / split 等)は [@nitpicker/archive](../archive/README.md) が担い、このパッケージはクロールの制御(puppeteer / beholder / dealer)だけを持ちます。
3
+ ヘッドレスブラウザでWebサイトをクロールし、`.nitpicker`アーカイブを生成・更新する内部パッケージです。アーカイブ自体の読み書き(スキーマ・マイグレーション・concat/split 等)は[@nitpicker/archive](../archive/README.md)が担い、このパッケージはクロールの制御(puppeteer/beholder/dealer)だけを持ちます。
4
4
 
5
- 通常は [@nitpicker/cli](../cli/README.md) の `crawl` コマンドから利用します。
5
+ 通常は[@nitpicker/cli](../cli/README.md)の`crawl`コマンドから利用します。
6
6
 
7
7
  ## 関連リンク
8
8
 
@@ -1996,7 +1996,7 @@ export default class Crawler extends EventEmitter {
1996
1996
  * @param headCheckResult - Optional HEAD result to pass to the scraper, avoiding a redundant request
1997
1997
  * @returns The scrape result from beholder
1998
1998
  */
1999
- // eslint-disable-next-line no-restricted-syntax -- intentional `private` (vs `#`) so tests can spyOn the prototype to drive the puppeteer-fallback cascade-guard branches without a full browser mock; see JSDoc above.
1999
+ // Intentional `private` (vs `#`) so tests can spyOn the prototype to drive the puppeteer-fallback cascade-guard branches without a full browser mock; see JSDoc above.
2000
2000
  async _launchBrowserAndScrape(url, update, isExternal, metadataOnly, headCheckResult) {
2001
2001
  update('Launching browser%dots%');
2002
2002
  if (this.#options.executablePath) {
@@ -13,8 +13,8 @@ import type { DedupeCapObservationRow } from '@nitpicker/archive/types';
13
13
  * its threshold when the previous session ended would restart at count 0.
14
14
  *
15
15
  * Mirrors the exact exclusions the live crawl-time observation site applies
16
- * (`Crawler`'s `'page'` handler, gated on `!isExternal && !isMetadataOnly &&
17
- * html.length > 0`): `listDedupeCapObservations` already narrows to that
16
+ * (`Crawler`'s `'page'` handler, gated on
17
+ * `!isExternal && !isMetadataOnly && html.length > 0`): `listDedupeCapObservations` already narrows to that
18
18
  * same population at the SQL layer, so this function only needs to redo
19
19
  * the two per-row signal computations that can independently yield "no
20
20
  * signal" — `computeShapeKey` (a URL that fails to decompose) and
@@ -14,8 +14,8 @@ import { resolveOgUrlMismatch } from './resolve-og-url-mismatch.js';
14
14
  * its threshold when the previous session ended would restart at count 0.
15
15
  *
16
16
  * Mirrors the exact exclusions the live crawl-time observation site applies
17
- * (`Crawler`'s `'page'` handler, gated on `!isExternal && !isMetadataOnly &&
18
- * html.length > 0`): `listDedupeCapObservations` already narrows to that
17
+ * (`Crawler`'s `'page'` handler, gated on
18
+ * `!isExternal && !isMetadataOnly && html.length > 0`): `listDedupeCapObservations` already narrows to that
19
19
  * same population at the SQL layer, so this function only needs to redo
20
20
  * the two per-row signal computations that can independently yield "no
21
21
  * signal" — `computeShapeKey` (a URL that fails to decompose) and
@@ -24,9 +24,7 @@ export async function fetchRobotsTxt(origin, userAgent) {
24
24
  return new Promise((resolve) => {
25
25
  const protocol = robotsUrl.startsWith('https') ? redirects.https : redirects.http;
26
26
  const req = protocol.get(robotsUrl, {
27
- headers: {
28
- ...(userAgent ? { 'User-Agent': userAgent } : {}),
29
- },
27
+ headers: userAgent ? { 'User-Agent': userAgent } : {},
30
28
  timeout: 10_000,
31
29
  }, (res) => {
32
30
  if (res.statusCode !== 200) {
@@ -103,7 +103,9 @@ async function readLeadingBytes(url, byteLimit, timeout, userAgent) {
103
103
  clearTimeout(timeoutHandle);
104
104
  destroyed = true;
105
105
  req.destroy();
106
- resolve(Buffer.concat(chunks));
106
+ // A single chunk can straddle the cap (the socket may deliver far more
107
+ // than `byteLimit` at once), so trim to the cap or a match beyond it leaks in.
108
+ resolve(Buffer.concat(chunks).subarray(0, byteLimit));
107
109
  }
108
110
  });
109
111
  res.on('end', () => {
@@ -178,7 +178,6 @@ export class CrawlerOrchestrator extends EventEmitter {
178
178
  get archive() {
179
179
  return this.#archive;
180
180
  }
181
- // eslint-disable-next-line no-restricted-syntax
182
181
  constructor(archive, options) {
183
182
  super();
184
183
  this.#fromList = !!options?.list;
@@ -496,7 +495,7 @@ export class CrawlerOrchestrator extends EventEmitter {
496
495
  networkOutageSummaryCounter.confirmedCount++;
497
496
  networkOutageSummaryCounter.totalDurationMs += durationMs;
498
497
  crawlerLog('Network outage recovered: id=%d endedAt=%d', id, endedAt);
499
- // eslint-disable-next-line no-console -- see the confirmed handler above
498
+ // oxlint-disable-next-line no-console -- see the confirmed handler above
500
499
  console.error(`[network] recovered after ${Math.round(durationMs / 1000)}s`);
501
500
  return this.#archive.closeNetworkOutage(id, endedAt);
502
501
  })
@@ -833,7 +832,9 @@ export class CrawlerOrchestrator extends EventEmitter {
833
832
  // few lines below, and a test-mocked `Archive` may return
834
833
  // `{ scraped, pending }` without the field (production's real
835
834
  // `getCrawlingState()` always includes it).
836
- const { scraped, pending, pendingMetadataOnly = [], } = await this.#archive.getCrawlingState();
835
+ const { scraped, pending,
836
+ // oxlint-disable-next-line typescript/no-useless-default-assignment -- the type is never nullish, the default only serves mocked archives
837
+ pendingMetadataOnly = [], } = await this.#archive.getCrawlingState();
837
838
  if (pending.length === 0) {
838
839
  return;
839
840
  }
@@ -878,7 +879,7 @@ export class CrawlerOrchestrator extends EventEmitter {
878
879
  this.#lanes.header(`[auto-retry] ${pending.length} pending page(s) remain — retry ${attempt}/${this.#maxAutoRetry} in %countdown(${delayMs},autoRetry,s)%s`);
879
880
  }
880
881
  else {
881
- // eslint-disable-next-line no-console -- see comment above
882
+ // oxlint-disable-next-line no-console -- see comment above
882
883
  console.error(`[auto-retry] ${pending.length} pending page(s) remain — waiting ${Math.round(delayMs / 1000)}s before retry ${attempt}/${this.#maxAutoRetry}`);
883
884
  }
884
885
  await delayOrAbort(delayMs, this.#crawler.signal);
@@ -1134,7 +1135,9 @@ export class CrawlerOrchestrator extends EventEmitter {
1134
1135
  // to `withoutHashAndAuth` before comparing, matching how
1135
1136
  // `pendingMetadataOnly` entries are normalised (see the
1136
1137
  // list-mode `resume`'s identical comment).
1137
- const { scraped, pending, pendingMetadataOnly = [], } = await archive.getCrawlingState();
1138
+ const { scraped, pending,
1139
+ // oxlint-disable-next-line typescript/no-useless-default-assignment -- the type is never nullish, the default only serves mocked archives
1140
+ pendingMetadataOnly = [], } = await archive.getCrawlingState();
1138
1141
  const mergedRootKeys = new Set(mergedRoots
1139
1142
  .map((root) => parseUrl(root, mergedConfig)?.withoutHashAndAuth)
1140
1143
  .filter((root) => root !== undefined));
@@ -1331,7 +1334,7 @@ export class CrawlerOrchestrator extends EventEmitter {
1331
1334
  setupProgress.onLog(message);
1332
1335
  }
1333
1336
  else {
1334
- // eslint-disable-next-line no-console -- --silent has no TaskList row to report through
1337
+ // oxlint-disable-next-line no-console -- --silent has no TaskList row to report through
1335
1338
  console.warn(message);
1336
1339
  }
1337
1340
  }
@@ -1656,7 +1659,7 @@ export class CrawlerOrchestrator extends EventEmitter {
1656
1659
  setupProgress.onLog(message);
1657
1660
  }
1658
1661
  else {
1659
- // eslint-disable-next-line no-console -- --silent has no TaskList row to report through
1662
+ // oxlint-disable-next-line no-console -- --silent has no TaskList row to report through
1660
1663
  console.warn(message);
1661
1664
  }
1662
1665
  }
@@ -1673,7 +1676,7 @@ export class CrawlerOrchestrator extends EventEmitter {
1673
1676
  setupProgress.onLog(message);
1674
1677
  }
1675
1678
  else {
1676
- // eslint-disable-next-line no-console -- --silent has no TaskList row to report through
1679
+ // oxlint-disable-next-line no-console -- --silent has no TaskList row to report through
1677
1680
  console.warn(message);
1678
1681
  }
1679
1682
  }
@@ -1713,7 +1716,7 @@ export class CrawlerOrchestrator extends EventEmitter {
1713
1716
  setupProgress.onLog(summaryMessage);
1714
1717
  }
1715
1718
  else {
1716
- // eslint-disable-next-line no-console -- --silent has no TaskList row to report through
1719
+ // oxlint-disable-next-line no-console -- --silent has no TaskList row to report through
1717
1720
  console.warn(summaryMessage);
1718
1721
  }
1719
1722
  const { htmlSeeds, nonHtmlSeeds } = await CrawlerOrchestrator.#ingestNovelSeeds({
@@ -2231,7 +2234,9 @@ export class CrawlerOrchestrator extends EventEmitter {
2231
2234
  throw new Error(`URL (${_url}) is invalid`);
2232
2235
  }
2233
2236
  setupProgress?.onPhase?.(PHASE_LOADING_CRAWL_STATE);
2234
- const { scraped, pending, pendingMetadataOnly = [], } = await archive.getCrawlingState();
2237
+ const { scraped, pending,
2238
+ // oxlint-disable-next-line typescript/no-useless-default-assignment -- the type is never nullish, the default only serves mocked archives
2239
+ pendingMetadataOnly = [], } = await archive.getCrawlingState();
2235
2240
  // Unlike `append`/`inventory`/`recrawl`/`retryFailed`, this path
2236
2241
  // resumes ANY archive including list-mode ones (`fromList: true`,
2237
2242
  // `recursive: false`) — exactly the #369 scenario. `config.roots`
@@ -2308,7 +2313,7 @@ export class CrawlerOrchestrator extends EventEmitter {
2308
2313
  dnsBurnedHostCache.set(host, 'dns');
2309
2314
  }
2310
2315
  if (hosts.length > 0) {
2311
- // eslint-disable-next-line no-console
2316
+ // oxlint-disable-next-line no-console
2312
2317
  console.error(`[preload] DNS-burned hosts: ${hosts.length} (will short-circuit subsequent URLs)`);
2313
2318
  }
2314
2319
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nitpicker/crawler",
3
- "version": "0.25.0",
3
+ "version": "0.25.2",
4
4
  "description": "Web crawler engine with headless browser rendering (writes .nitpicker archives via @nitpicker/archive)",
5
5
  "author": "D-ZERO",
6
6
  "license": "Apache-2.0",
@@ -30,20 +30,20 @@
30
30
  "clean": "tsc --build --clean"
31
31
  },
32
32
  "dependencies": {
33
- "@d-zero/beholder": "5.0.0",
34
- "@d-zero/dealer": "1.14.0",
35
- "@d-zero/shared": "0.23.0",
36
- "@nitpicker/archive": "0.25.0",
33
+ "@d-zero/beholder": "5.0.3",
34
+ "@d-zero/dealer": "1.14.2",
35
+ "@d-zero/shared": "0.23.2",
36
+ "@nitpicker/archive": "0.25.2",
37
37
  "ansi-colors": "4.1.3",
38
38
  "debug": "4.4.3",
39
- "follow-redirects": "1.16.1",
39
+ "follow-redirects": "1.16.3",
40
40
  "knex": "3.3.0",
41
- "puppeteer": "25.5.0",
42
- "robots-parser": "3.0.1"
41
+ "puppeteer": "25.15.0",
42
+ "robots-parser": "3.1.2"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@types/debug": "4.1.13",
46
46
  "@types/follow-redirects": "1.14.4"
47
47
  },
48
- "gitHead": "fb258acf112366504c6dbb44b69a25bbc528fa30"
48
+ "gitHead": "3dc201cd82b0986c6f90a5d54e790f00d1503b96"
49
49
  }