Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

bhokaremoin
Copy link
Contributor

@bhokaremoin bhokaremoin commented Jul 29, 2025

Added support for making canvas serialization fail-safe.

Passing ignoreCanvasSerializationErrors in snapshot options or at global config. ignore any errors that occur during canvas serialization. And instead renders a broken Img.

@bhokaremoin bhokaremoin requested a review from a team as a code owner July 29, 2025 19:57
@bhokaremoin bhokaremoin changed the title adding fail-safe option for serialize canvas ✨ Adding support for ignoreCanvasSerializationErrors Jul 30, 2025
@bhokaremoin bhokaremoin requested a review from Copilot July 30, 2025 18:10
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for making canvas serialization fail-safe by introducing an ignoreCanvasSerializationErrors configuration option. When enabled, canvas serialization errors are caught and handled gracefully by rendering a fallback broken image instead of throwing errors.

  • Adds ignoreCanvasSerializationErrors configuration option at both global config and snapshot levels
  • Modifies canvas serialization to catch errors and create fallback image elements when the flag is enabled
  • Refactors canvas serialization code to extract image element creation into a reusable helper function

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/core/src/config.js Adds schema definition for the new ignoreCanvasSerializationErrors boolean configuration option
packages/core/src/page.js Passes the ignoreCanvasSerializationErrors option through the snapshot capture pipeline
packages/core/src/discovery.js Adds debug logging for the new configuration option
packages/dom/src/serialize-dom.js Extracts and passes the ignoreCanvasSerializationErrors option to the serialization context
packages/dom/src/serialize-canvas.js Refactors canvas serialization to handle errors gracefully and create fallback images when flag is enabled
packages/dom/test/serialize-dom.test.js Adds tests for the new error handling behavior in DOM serialization
packages/dom/test/serialize-canvas.test.js Adds comprehensive tests for canvas error handling and fallback image creation
packages/core/test/percy.test.js Updates test expectations to include the new configuration option
Comments suppressed due to low confidence (1)

packages/dom/test/serialize-dom.test.js:471

  • This test is identical to the previous test case 'ignores canvas serialization errors when flag is enabled'. The test name suggests it should verify the flag is picked from options, but it doesn't test anything different or demonstrate how options are prioritized.
    it('picks ignoreCanvasSerializationErrors flag from options', () => {

@bhokaremoin bhokaremoin added the ✨ enhancement New feature or request label Jul 30, 2025
@bhokaremoin bhokaremoin merged commit 4103486 into master Aug 1, 2025
116 of 126 checks passed
@bhokaremoin bhokaremoin deleted the PVS-186 branch August 1, 2025 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants