Repository navigation
Respect ignoreErrors when onResourceSaved action fails - #668
Merged
Merged
Conversation
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>
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.
Follow-up to #658 (issue #657).
After #658 a failing
onResourceSavedaction no longer crashes the process, but its error is only written to thewebsite-scraper:warndebug logger, which is hidden by default. Errors from every other action (beforeRequest,afterResponse,generateFilename,getReference,saveResource) go throughhandleError()and respectignoreErrors. 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
onResourceSavedaction is now handled like any other resource error:onResourceErroris called for the resource.ignoreErrors: true: the error is logged and scraping continues.ignoreErrors: false(default):scrape()waits for pending notification actions, then runs theerroraction andafterFinishand rejects with that error. The action isn't awaited during scraping, so this happens after downloading is finished, not immediately.Errorrejection values are wrapped in anError.onResourceErrorfailures stay log-only. WithignoreErrors: falsethe scrape is already failing, and replacing the original error would hide the real cause. Routing them throughhandleErrorcould also recurse.onResourceSavedandignoreErrors.Behavior change
Before #658 a rejected
onResourceSavedcaused an unhandled rejection, which crashes Node by default, so nobody can rely on it being ignored. With the defaultignoreErrors: false, such a failure now rejectsscrape(). It should still go in the changelog for the next minor release.Tests
onResourceSavedrejects,ignoreErrors: true:onResourceErroris called,afterFinishruns,scrape()resolves, no unhandled rejection.onResourceSavedrejects,ignoreErrors: false: order isonResourceError→error→afterFinish, andscrape()rejects with the original error.onResourceErrorrejects,ignoreErrors: false:scrape()rejects with the original request error.onResourceSavedtests fail against current master.🤖 Generated with Claude Code