Skip to content

build_pkgdown.R - build_quietly() can't muffle and resume warnings when using tryCatch #4034

Description

@divine7022

follow-up from #4033

In scripts/build_pkgdown.R, build_quietly() collects warnings via tryCatch(..., warning = function(w) {...}). A tryCatch warning handler is an exiting handler, per ?conditions, control unwinds to the tryCatch frame before the handler runs, so (a) muffleWarning restart from the signalling context is no longer available, and (b) handler returning abandons the build_and_copy() call rather than resuming it.
This is consistent with the existing # TODO this branch doesn't ever seem to run comment, pkgdown appears to muffle its own warnings before they propagate here, and with the no 'restart' 'muffleWarning' found error that #4033 worked around with tryInvokeRestart. #4033 correctly stops the crash and is the variant ?conditions recommends; this issue is only about the structure.
If we want build_quietly() to actually collect warnings and keep building, use withCallingHandlers for the warning branch (handler runs in the signalling context, where muffleWarning is still available), keeping tryCatch for error.

Acceptance criteria:

  • warning emitted during a pkgdown build is captured in the returned warnings list without aborting that package's build
  • the warning is muffled (not double printed)
  • stale # TODO ... doesn't ever seem to run comment is reconciled once the branch works

low priority, since #4033 already resolves the CI failure. This just makes the warning collection work as intended

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions