Skip to content

Respect ignoreErrors when onResourceSaved action fails - #668

Merged
aivus merged 1 commit into
masterfrom
on-resource-saved-respect-ignore-errors
Nov 8, 2026
Merged

aivus merged 1 commit into
masterfrom
on-resource-saved-respect-ignore-errors

Conversation

@aivus

@aivus aivus commented Nov 8, 2026

Copy link
Copy Markdown
Member

Follow-up to #658 (issue #657).

After #658 a failing onResourceSaved action no longer crashes the process, but its error is only written to the website-scraper:warn debug logger, which is hidden by default. Errors from every other action (beforeRequest, afterResponse, generateFilename, getReference, saveResource) go through handleError() and respect ignoreErrors. A plugin that post-processes saved files (the use case from #657) can leave broken output on disk, so silently continuing is the wrong default.

Changes

  • A failing onResourceSaved action is now handled like any other resource error:
    • onResourceError is called for the resource.
    • ignoreErrors: true: the error is logged and scraping continues.
    • ignoreErrors: false (default): scrape() waits for pending notification actions, then runs the error action and afterFinish and rejects with that error. The action isn't awaited during scraping, so this happens after downloading is finished, not immediately.
    • Non-Error rejection values are wrapped in an Error.
  • onResourceError failures stay log-only. With ignoreErrors: false the scrape is already failing, and replacing the original error would hide the real cause. Routing them through handleError could also recurse.
  • README: documented under onResourceSaved and ignoreErrors.

Behavior change

Before #658 a rejected onResourceSaved caused an unhandled rejection, which crashes Node by default, so nobody can rely on it being ignored. With the default ignoreErrors: false, such a failure now rejects scrape(). It should still go in the changelog for the next minor release.

Tests

  • onResourceSaved rejects, ignoreErrors: true: onResourceError is called, afterFinish runs, scrape() resolves, no unhandled rejection.
  • onResourceSaved rejects, ignoreErrors: false: order is onResourceError → error → afterFinish, and scrape() rejects with the original error.
  • onResourceError rejects, ignoreErrors: false: scrape() rejects with the original request error.
  • The two onResourceSaved tests fail against current master.

🤖 Generated with Claude Code

A failing onResourceSaved action was only logged to the debug logger, while
errors from every other action go through handleError and respect
ignoreErrors. Handle it the same way: call onResourceError for the resource
and, with ignoreErrors = false, reject scrape() with the error once pending
notification actions are finished.

onResourceError failures stay log-only so they don't replace the original
error or recurse.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@aivus
aivus merged commit e2b75d7 into master Nov 8, 2026
14 checks passed
@aivus
aivus deleted the on-resource-saved-respect-ignore-errors branch November 8, 2026 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant