percy / percy-storybook

Percy's Storybook SDK.
https://docs.percy.io/docs/storybook
MIT License
150 stars 45 forks source link

Percy Storybook: Cannot find context with specified id #779

Closed michaellamScore closed 1 year ago

michaellamScore commented 1 year ago

The problem

Trying to snapshot storybook-static build and running the command: percy storybook ./storybook-static --verbose --debug

However, I receive the error: [percy] Error: Protocol error (Runtime.callFunctionOn): Cannot find context with specified id [percy] Error: Protocol error (Runtime.callFunctionOn): Execution context was destroyed.

Environment

Dependencies: "@percy/cli": "^1.26.2", "@percy/playwright": "1.0.4", "@percy/storybook": "4.3.6", "@playwright/test": "1.36.0", "@storybook/addon-a11y": "6.5.16", "@storybook/addon-actions": "6.5.16", "@storybook/addon-essentials": "6.5.16", "@storybook/addon-interactions": "6.5.16", "@storybook/addon-links": "6.5.16", "@storybook/builder-webpack5": "6.5.16", "@storybook/manager-webpack5": "6.5.16", "@storybook/react": "6.5.16", "@storybook/testing-library": "0.2.0",

Details

If necessary, describe the problem you have been experiencing in more detail. Unable to create a percy build because of the above issue. Currently not with Storybook v7, on v6.5.16

Screenshot 2023-07-19 at 8 37 34 AM Screenshot 2023-07-19 at 11 19 16 AM

Debug logs

If you are reporting a bug, always include logs! Give the "Debugging SDKs" document a quick read for how to gather logs

Sample StackTrace: [percy:core:page] Page created (24ms) [percy:core:page] Navigate to: http://localhost:54731/iframe.html (44ms) [percy:core:page] Page navigated (440ms) [percy:core:page] Page closed (3ms) [percy:core] Stopping percy... (0ms) [percy:core:browser] Closing browser (1ms) [percy:core:browser] Browser closed (12ms) [percy:core] Build not created (1ms) [percy:cli] Error: Protocol error (Runtime.callFunctionOn): Cannot find context with specified id at file:///Users/michael/.asdf/installs/nodejs/16.13.2/lib/node_modules/@percy/cli/node_modules/@percy/core/dist/session.js:45:16 at new Promise () at Session.send (file:///Users/michael/.asdf/installs/nodejs/16.13.2/lib/node_modules/@percy/cli/node_modules/@percy/core/dist/session.js:43:12) at async Page.eval (file:///Users/michael/.asdf/installs/nodejs/16.13.2/lib/node_modules/@percy/cli/node_modules/@percy/core/dist/page.js:106:9) at async file:///Users/michael/Documents/project_name/node_modules/@percy/storybook/dist/snapshots.js:204:11 at async yieldTo (file:///Users/michael/Documents/project_name/node_modules/@percy/core/dist/utils.js:121:36) at async withPage (file:///Users/michael/Documents/project_name/node_modules/@percy/storybook/dist/utils.js:104:12) at async takeStorybookSnapshots (file:///Users/michael.lam/Documents/project_name/node_modules/@percy/storybook/dist/snapshots.js:187:5) at async Object.callback (file:///Users/michael/Documents/project_name/node_modules/@percy/storybook/dist/storybook.js:36:3) at async generatePromise (file:///Users/michael.lam/.asdf/installs/nodejs/16.13.2/lib/node_modules/@percy/cli/node_modules/@percy/core/dist/utils.js:85:115) (0ms)

Code to reproduce issue

Given the nature of testing/environment bugs, it’s best to try and isolate the issue in a reproducible repo. This will make it much easier for us to diagnose and fix.

Unable to provide code suite to reproduce, but don't have any insights on the error log. I have only found issues relating the puppeteer.

itsjwala commented 1 year ago

hey @michaellamScore 👋

we're checking this issue through support as you may already know, lets's take our discussion from there.

thomasparsons commented 1 year ago

@itsjwala is there a fix for this, as I am having this same issue and there doesn't seem to be any documentation or actionable steps written anywhere

itsjwala commented 1 year ago

@thomasparsons 👋

1) it might happen if you're using storybook v7, we already have an issue open #715

2) This error arises when the browser page that loads the story might have changed (due to page reload, or page crash)

what you could do to debug is turn headless: false in the configuration https://docs.percy.io/docs/cli-configuration#discovery and observe when this is happening, what is the state of the page, it might be the page required was prematurely closed, in which case waitForTimeout: 1000 would be useful - https://docs.percy.io/docs/storybook#percy-config-file-options

we'll add it to our debugging sdk docs, thanks for raising it.

Let us know how it goes, if this is still an issue please reach us via support with minimal reproducible example, we'd be happy to assist.