Open acbonnyac opened 1 year ago
Here's the current workaround I'm using to get around this by spawning a Storybook server ahead and have my own timeout:
import { spawn } from 'child_process';
import { chromium } from 'playwright';
import waitOn from 'wait-on';
async function spawnStorybookServer() {
const storybookUrl = 'http://localhost:6006';
console.log(`Starting Storybook server with "npm run ${storybookCommand}"`);
const storybookServer = spawn(`npm run ${storybookCommand}`, { shell: true });
console.log(`Waiting for Storybook server to start at ${storybookUrl}`);
await waitOn({ resources: [storybookUrl], timeout: storybookServerTimeout });
console.log('Storybook server started');
console.log('Waiting for Storybook to finish loading');
const browser = await chromium.launch({
args: ['--no-sandbox', '--disable-setuid-sandbox', '--disable-dev-shm-usage'],
executablePath: process.env.CHROME_PATH,
});
const page = await browser.newPage();
await page.goto(storybookUrl, { timeout: storybookLoadTimeout });
await browser.close();
console.log('Storybook finished loading');
return storybookServer;
}
await spawnStorybookServer();
This is a code snippet so there are some variables that need to be replaced. But you should get an idea.
In our team CI/CD pipeline, sometimes it can be slow and failed with timeout error while waiting for Storybook definitions.
Here's an error message:
If I'm guessing right, it probably failed on this line https://github.com/reg-viz/storycap/blob/master/packages/storycrawler/src/browser/stories-browser.ts#L56 while it's waiting for the page to be fully loaded. By default page.goto probably has a timeout of 30 seconds.
If so, could someone help create this as a new option that we can customize, just like
serverTimeout
? Maybe we can addstoriesDefinitionTimeout
as another option?