Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Navigation timeout of 30000 ms exceeded while waiting for stories definition #800

Open
acbonnyac opened this issue Aug 2, 2023 · 1 comment

Comments

@acbonnyac
Copy link

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:

info Executable Chromium path: /usr/bin/chromium
debug Wait for stories definition.
info => Using default Webpack5 setup
<A bunch of debug logs like "<s> [webpack.Progress] 75% sealing chunk optimization MergeDuplicateChunksPlugin">
error Navigation timeout of 30000 ms exceeded
TimeoutError: Navigation timeout of 30000 ms exceeded
    at <projectRootDir>/node_modules/puppeteer-core/lib/cjs/puppeteer/common/LifecycleWatcher.js:106:111

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 add storiesDefinitionTimeout as another option?

@acbonnyac
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant