feat(beholder): capture console messages and page errors#925
Merged
Conversation
Collect console.log/warn/error/etc. and uncaught exceptions /
unhandled promise rejections via page.on('console')/('pageerror'),
for internal pages only. Returned as ScrapeResult.consoleLogs
(ConsoleLogEntry[]), mirroring the existing resources array pattern
rather than embedding into PageData.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
console.log/warn/error/etc. and uncaught exceptions / unhandled promise rejections during page scraping, for internal pages only (isExternal: false), viapage.on('console')/page.on('pageerror').ScrapeResult.consoleLogs(ConsoleLogEntry[]), mirroring the existingresources/pageUrlpattern rather than embedding intoPageData— matches how sub-resources are already collected as a page-scoped array, not a per-page-data field.#fetchData's navigation/extraction body is now wrapped intry { ... } finally { await Promise.all(pendingConsoleWork); }, so asyncjsonValue()argument resolution is guaranteed to settle before the function returns or throws (previously-considered per-return-statement awaits would have missed the two thrown-error exit paths and let a@retryableretry contaminate the array with a stale attempt's late resolutions).ConsoleLogEntryis exported from the package's public entry point alongsideResourceEntry/NetworkLog.Scope:
@d-zero/beholderonly. This is a producer-side addition (ScrapeResultgains a new required field); no consumer in this repo constructsScrapeResultliterals, so nothing else intoolsneeded updating. A downstream consumer (nitpicker, separate repo) does constructScrapeResult-shaped literals in a few places and will need a small follow-up there — tracked separately, out of scope for this PR.Test plan
yarn build(viaNX_WORKSPACE_ROOT_PATH) — no type errorsyarn lint— 0 errors (pre-existing unrelated warnings only)yarn test— 113 files / 1612 tests pass, including newto-console-log-entry.spec.ts/to-page-error-entry.spec.tscovering: per-type propagation, mixed success/failureargs()resolution,dispose()invocation,locationpresence/absence, andpageerrorfor bothErrorand non-Errorthrow valuesscraper.ts's own listener wiring (onConsole/onPageError, thetry/finallyflush) has no direct unit test — Vitest's esbuild-based transform cannot parse this file due to the pre-existing@retryabledecorator on a private method (#fetchData); confirmed by reproducingSyntaxError: Private field '#fetchData' must be declared in an enclosing classwhen attempting to add a spec file. This is a pre-existing toolchain limitation (no spec file has ever importedscraper.ts), not introduced by this change.