Shopify / lighthouse-ci-action

MIT License
100 stars 50 forks source link

Lighthouse looking for password somewhere on clean Dawn theme #33

Open Avex-Dev opened 2 years ago

Avex-Dev commented 2 years ago

I am working right off a download of a clean Dawn theme following https://shopify.dev/themes/getting-started/create which has a password page, however, the password is not active, and I am getting the following error:

Configuring shopify CLI
Will run Lighthouse CI on https://***
==============================
Creating development theme
{"theme":{"id":128112328866,"name":"Development (a77b97-d351661ce68d)","role":"development","shop":"***","editor_url":"https://***/admin/themes/128112328866/editor","preview_url":"https://***/?preview_theme_id=128112328866"}}
==============================
Configuring Lighthouse CI
==============================
Running Lighthouse CI
✅  .lighthouseci/ directory writable
✅  Configuration file found
✅  Chrome installation found
✅  GitHub token set
Healthcheck passed!

Getting a new page...
Getting password cookie...
TimeoutError: waiting for selector `form[action*=password] input[type="password"]` failed: timeout 30000ms exceeded
    at new WaitTask (/.node/lib/node_modules/puppeteer/lib/cjs/puppeteer/common/DOMWorld.js:509:34)
    at DOMWorld.waitForSelectorInPage (/.node/lib/node_modules/puppeteer/lib/cjs/puppeteer/common/DOMWorld.js:420:26)
    at Object.internalHandler.waitFor (/.node/lib/node_modules/puppeteer/lib/cjs/puppeteer/common/QueryHandler.js:31:77)
    at DOMWorld.waitForSelector (/.node/lib/node_modules/puppeteer/lib/cjs/puppeteer/common/DOMWorld.js:313:29)
    at Frame.waitForSelector (/.node/lib/node_modules/puppeteer/lib/cjs/puppeteer/common/FrameManager.js:841:51)
    at Page.waitForSelector (/.node/lib/node_modules/puppeteer/lib/cjs/puppeteer/common/Page.js:2238:33)
    at module.exports (/github/workspace/setPreviewCookies.js:9:16)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async PuppeteerManager.invokePuppeteerScriptForUrl (/.node/lib/node_modules/@lhci/cli/src/collect/puppeteer-manager.js:108:5)

    at async Object.runCommand (/.node/lib/node_modules/@lhci/cli/src/collect/collect.js:240:7)

Originally posted by @Avex-Dev in https://github.com/Shopify/lighthouse-ci-action/issues/15#issuecomment-1004291159

govrayt commented 2 years ago

Hey @Avex-Dev I've worked out how to fix this...

If your store isn't password protected (via Shopify Admin) - don't set the 'SHOP_PASSWORD' secret in your repo, this will then bypass the password page check in lighthouse check.

It would also help if Shopify updated their documentation to explain this!

The below explains why (found in entrypoint.sh file within this repo)

if ('$shop_password' !== '') { console.error('Getting password cookie...'); await page.goto('$host/password'); await page.waitForSelector('form[action*=password] input[type="password"]'); await page.\$eval('form[action*=password] input[type="password"]', input => input.value = '$shop_password'); await Promise.all([ page.waitForNavigation(), page.\$eval('form[action*=password]', form => form.submit()), ]) }

Adnandeardigital commented 10 months ago

Hey guys, I'm also facing the same issue. In my case, I have a development store, and it's password-protected. I've added the correct password, but I'm still getting the following error log. Has this issue been resolved by any chance? or this is only for stores that are not having password protection ? 🤔

==============================
Running Lighthouse CI
✅  .lighthouseci/ directory writable
✅  Configuration file found
✅  Chrome installation found
✅  GitHub token set
Healthcheck passed!

Getting a new page...
Getting password cookie...
Getting preview cookie...
Running Lighthouse 3 time(s) on https://***/?preview_theme_id=1673812014&_fd=0&pb=0
Run #1...done.
Run #2...done.
Getting a new page...
Run #3...done.
Getting password cookie...
TimeoutError: waiting for selector `form[action*=password] input[type="password"]` failed: timeout 30000ms exceeded
    at new WaitTask (/.node/lib/node_modules/puppeteer/lib/cjs/puppeteer/common/DOMWorld.js:509:34)
    at DOMWorld.waitForSelectorInPage (/.node/lib/node_modules/puppeteer/lib/cjs/puppeteer/common/DOMWorld.js:420:[26](https://github.com/Adnandeardigital/another-shopify-repo/actions/runs/6561257071/job/17821113831#step:4:27))
    at Object.internalHandler.waitFor (/.node/lib/node_modules/puppeteer/lib/cjs/puppeteer/common/QueryHandler.js:31:77)
    at DOMWorld.waitForSelector (/.node/lib/node_modules/puppeteer/lib/cjs/puppeteer/common/DOMWorld.js:313:[29](https://github.com/Adnandeardigital/another-shopify-repo/actions/runs/6561257071/job/17821113831#step:4:30))
    at Frame.waitForSelector (/.node/lib/node_modules/puppeteer/lib/cjs/puppeteer/common/FrameManager.js:841:51)
    at Page.waitForSelector (/.node/lib/node_modules/puppeteer/lib/cjs/puppeteer/common/Page.js:2238:[33](https://github.com/Adnandeardigital/another-shopify-repo/actions/runs/6561257071/job/17821113831#step:4:34))
    at module.exports (/github/workspace/setPreviewCookies.js:9:16)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async PuppeteerManager.invokePuppeteerScriptForUrl (/.node/lib/node_modules/@lhci/cli/src/collect/puppeteer-manager.js:108:5)

    at async Object.runCommand (/.node/lib/node_modules/@lhci/cli/src/collect/collect.js:2[40](https://github.com/Adnandeardigital/another-shopify-repo/actions/runs/6561257071/job/17821113831#step:4:41):7)
jgiordanoGG commented 5 months ago

Bumping this because we starting seeing this quite literally out of the blue. We've had this set up and working without issue for weeks. Then today one minute it was working, the next, every single push gets the same result:

==============================
Configuring Lighthouse CI
Fetching product handle
Using amazing-aluminum-bag-collection1
==============================
Running Lighthouse CI
✅  .lighthouseci/ directory writable
✅  Configuration file found
✅  Chrome installation found
✅  GitHub token set
Healthcheck passed!

Getting a new page...
Getting password cookie...
TimeoutError: Waiting for selector `form[action*=password] input[type="password"]` failed: Waiting failed: 30000ms exceeded
    at new WaitTask (/.node/lib/node_modules/puppeteer/node_modules/puppeteer-core/lib/cjs/puppeteer/common/WaitTask.js:50:34)
    at IsolatedWorld.waitForFunction (/.node/lib/node_modules/puppeteer/node_modules/puppeteer-core/lib/cjs/puppeteer/api/Realm.js:25:26)
    at PQueryHandler.waitFor (/.node/lib/node_modules/puppeteer/node_modules/puppeteer-core/lib/cjs/puppeteer/common/QueryHandler.js:1[70](https://github.com/ubergreatergood/gg-unite/actions/runs/8459335518/job/23175463701#step:4:71):95)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async CdpFrame.waitForSelector (/.node/lib/node_modules/puppeteer/node_modules/puppeteer-core/lib/cjs/puppeteer/api/Frame.js:494:21)
    at async CdpPage.waitForSelector (/.node/lib/node_modules/puppeteer/node_modules/puppeteer-core/lib/cjs/puppeteer/api/Page.js:1295:20)
    at async module.exports (/github/workspace/setPreviewCookies.js:9:5)
    at async PuppeteerManager.invokePuppeteerScriptForUrl (/.node/lib/node_modules/@lhci/cli/src/collect/puppeteer-manager.js:113:5)
    at async Object.runCommand (/.node/lib/node_modules/@lhci/cli/src/collect/collect.js:251:7)

    at async run (/.node/lib/node_modules/@lhci/cli/src/cli.js:100:7)
eddysims commented 5 months ago

Also seeing this on a development shop that has a store password

==============================
Configuring Lighthouse CI
Fetching product handle
Using alpinist-2-cookware-system
==============================
Running Lighthouse CI
✅  .lighthouseci/ directory writable
✅  Configuration file found
✅  Chrome installation found
⚠️   GitHub token not set
Healthcheck passed!
Getting a new page...
Getting password cookie...
TimeoutError: Waiting for selector `form[action*=password] input[type="password"]` failed: Waiting failed: 30000ms exceeded
    at new WaitTask (/.node/lib/node_modules/puppeteer/node_modules/puppeteer-core/lib/cjs/puppeteer/common/WaitTask.js:[50](https://github.com/arrive-outdoors/shopify-theme-base/actions/runs/8471692315/job/23212756776#step:4:51):34)
    at IsolatedWorld.waitForFunction (/.node/lib/node_modules/puppeteer/node_modules/puppeteer-core/lib/cjs/puppeteer/api/Realm.js:25:26)
    at PQueryHandler.waitFor (/.node/lib/node_modules/puppeteer/node_modules/puppeteer-core/lib/cjs/puppeteer/common/QueryHandler.js:170:95)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async CdpFrame.waitForSelector (/.node/lib/node_modules/puppeteer/node_modules/puppeteer-core/lib/cjs/puppeteer/api/Frame.js:494:21)
    at async CdpPage.waitForSelector (/.node/lib/node_modules/puppeteer/node_modules/puppeteer-core/lib/cjs/puppeteer/api/Page.js:1295:20)
    at async module.exports (/github/workspace/setPreviewCookies.js:9:5)
    at async PuppeteerManager.invokePuppeteerScriptForUrl (/.node/lib/node_modules/@lhci/cli/src/collect/puppeteer-manager.js:113:5)
    at async Object.runCommand (/.node/lib/node_modules/@lhci/cli/src/collect/collect.js:2[51](https://github.com/arrive-outdoors/shopify-theme-base/actions/runs/8471692315/job/23212756776#step:4:52):7)
    at async run (/.node/lib/node_modules/@lhci/cli/src/cli.js:100:7)
##[debug]Docker Action run completed with exit code 1
##[debug]Finishing: Lighthouse
charlespwd commented 5 months ago

This error is shown when there isn't a form with an input of type password on your theme. e.g.

<form action="...password">
  <input type="password">
</form>

Did any of you change it? Did the platform change it? The above code made the assumption that this would be there on the password page.

jgiordanoGG commented 5 months ago

Hey @charlespwd , thanks for your reply! What you're saying makes total sense since the error was essentially saying it couldn't find form[action*=password] input[type="password"].

To test this I opened an incognito window, went to the myshopify url for the dev store in question, and immediately saw the password login form. The url even had /password at the end. I apologize if I'm not understanding or there's another place I should be checking, though we haven't — to the best of my knowledge — changed the password form. And since it's a dev store we can't even remove it. Is there perhaps another place or setting I can check?

Thanks again for your reply!

eddysims commented 5 months ago

@charlespwd Can also confirm that my store has a password with the proper elements:

image

and

image

jgiordanoGG commented 5 months ago

I see the same on the rendered page as @eddysims. In the code, however, I don't see a place where a change can be made to the form because it seems to be absent — or rather inside the {{content_for_layout}}. Looking at this I'm reminded that Shopify tends to lock things like this down in a black box so that you're unable to change forms of this nature. Here's the entire body within the password.liquid file of the Dawn theme:

<body class="password gradient">
    <a class="skip-to-content-link button visually-hidden" href="#MainContent">
      {{ 'accessibility.skip_to_text' | t }}
    </a>

    {% section 'main-password-header' %}

    <main id="MainContent" class="password-main">
      {{ content_for_layout }}
    </main>
    <footer>
      {% section 'main-password-footer' %}
    </footer>
    <ul hidden>
      <li id="a11y-new-window-message">{{ 'accessibility.link_messages.new_window' | t }}</li>
    </ul>
</body>
jgiordanoGG commented 5 months ago

Not sure if anyone else has seen a change today, but just as suddenly and inexplicably as this stopped working last week it started working again this morning. We haven't made any changes that I can imagine would impact this at all — certainly no changes to the password form since it's not something we have access to. Either way, just really grateful to see that little green checkmark again 😆

image
charlespwd commented 5 months ago

Ah I think it might be related to the Shopify CLI problem we were having. 5.80.0 introduced a regression on shopify theme push, and 5.80.2 fixed it. The TL;DR is that we finally got around migrating theme push from the ruby CLI to TS, and bugs were introduced in the transition.

Thanks for updating the issue. That must have been the root cause. I was really scratching my head on that one and didn't have capacity to look into it.

jgiordanoGG commented 5 months ago

No worries at all @charlespwd , and thanks for the additional info here! I appreciate you closing the loop for us!