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

Ubuntu-latest stopped running Node.Js script in Actions #6738

Closed
2 of 11 tasks
theDavidBarton opened this issue Dec 10, 2022 · 8 comments
Closed
2 of 11 tasks

Ubuntu-latest stopped running Node.Js script in Actions #6738

theDavidBarton opened this issue Dec 10, 2022 · 8 comments
Assignees
Labels
bug report investigate Collect additional information, like space on disk, other tool incompatibilities etc. OS: Ubuntu

Comments

@theDavidBarton
Copy link

Description

My Actions stopped working a few days ago (e.g.: see "Run main script" job) and I realized Actions using Ubuntu 22.04 and not 20.04. It is related to #6399. The main script just simply not executed. There is no error msg.

Reverting back to Ubuntu-20.04 solved the issue: https://github.com/theDavidBarton/koronavirus.gov.hu-scraper/actions/runs/3666215143/jobs/6197790588

Note: it won't fail the job, it will only silently skips script execution.

Platforms affected

  • Azure DevOps
  • GitHub Actions - Standard Runners
  • GitHub Actions - Larger Runners

Runner images affected

  • Ubuntu 18.04
  • Ubuntu 20.04
  • Ubuntu 22.04
  • macOS 10.15
  • macOS 11
  • macOS 12
  • Windows Server 2019
  • Windows Server 2022

Image version and build link

20221204.2 https://github.com/theDavidBarton/koronavirus.gov.hu-scraper/actions/runs/3666162585/jobs/6197707490

Is it regression?

20221204.2 https://github.com/theDavidBarton/koronavirus.gov.hu-scraper/actions/runs/3666215143/jobs/6197790588

Expected behavior

It should run the Node.Js script with 22.04 as before with 20.04.

Actual behavior

The Node.Js script is not executed.

Repro steps

  1. Run scrape job here https://github.com/theDavidBarton/koronavirus.gov.hu-scraper/actions/workflows/scrape.yml with an ubuntu-latest
  2. It won't run the Node.Js script but goes to the next job immediately
@igorboskovic3
Copy link
Contributor

Hi @theDavidBarton we will take a look, can you provide minimal repro steps?

@igorboskovic3 igorboskovic3 added OS: Ubuntu investigate Collect additional information, like space on disk, other tool incompatibilities etc. and removed needs triage labels Dec 12, 2022
@igorboskovic3
Copy link
Contributor

igorboskovic3 commented Dec 12, 2022

This is probably related to #6698

@theDavidBarton
Copy link
Author

Hi @theDavidBarton we will take a look, can you provide minimal repro steps?

I will create a fork of my repo where there is no MongoDB and as minimal as possible.

@theDavidBarton
Copy link
Author

theDavidBarton commented Dec 12, 2022

@igorboskovic3

minimal repro steps

prequisities:

package.json

{
  "dependencies": {
    "puppeteer": "^5.3.0"
  },
  "engines": {
    "node": "16.x"
  }
}

index.js

const puppeteer = require('puppeteer')

const runScrape = async () => {
  const browser = await puppeteer.launch()
  const page = await browser.newPage()
  await page.goto('https://koronavirus.gov.hu')
  console.log('the Node.Js script is launched successfully)
  await browser.close()
}
runScrape()

.github/workflows/scrape.yml

name: scrape

on:
  schedule:
    - cron: '30 9 * * *'
  workflow_dispatch:

jobs:
  scrape-and-publish:
    runs-on: ubuntu-latest
    environment:
      name: production

    steps:
      - uses: actions/checkout@v3
      - name: Use Node.js 16.x
        uses: actions/setup-node@v3
        with:
          node-version: 16.x
      - name: Install project
        run: yarn
      - name: Run main script
        run: node index.js

available here as well. I removed everything irrelevant from the point of view of the Ubuntu issue: https://github.com/Crocodiles-in-the-Basement/koronavirus.gov.hu-scraper

steps:

  1. trigger a workflow dispatch in Actions (https://github.com/Crocodiles-in-the-Basement/koronavirus.gov.hu-scraper/actions/workflows/scrape.yml)
  2. it will not run the Node.Js script with Ubuntu-latest (https://github.com/Crocodiles-in-the-Basement/koronavirus.gov.hu-scraper/actions/runs/3679654093/jobs/6224349730#step:5:2). the `the Node.Js script is launched successfully text never appears instead it immediately checks the job as succeed and the workflow ends.

@igorboskovic3
Copy link
Contributor

Hi @theDavidBarton, your issue is probably due MongoDB, which isn't installed on ubuntu-latest. You can see here that we don't have MongoDb on that image, I would recommend that you use ubuntu-20.04 image. Feel free to reach us if you have additional questions.

@theDavidBarton
Copy link
Author

hi @igorboskovic3,

thanks for the heads up. however, I am 100% sure it is not related to Mongo, see my minimal repro steps in my latest comment: #6738 (comment) which was not using MongoDB at all. also, that should have an error message in Actions, the current issue is rather the lack of errors (the script silently not executed via Node.Js) 🤔

indeed, I needed to downgrade to ubuntu-20.04 image manually, but I hope it will be fixed later on as I am afraid I will be stuck with a non-supported version in a few years. 🙏

@dsame dsame self-assigned this Dec 23, 2022
@dsame
Copy link
Contributor

dsame commented Dec 26, 2022

Hello @theDavidBarton

In fact there is a bunch of problems in the script.

The first one it looks like puppeteer instead of using preinstalled google-chrome has to download it. This can be solved with const browser = await puppeteer.launch({executablePath: '/usr/bin/google-chrome'})

@igorboskovic3 I suppose the problem above caused the images has not most-recent version of google-chrome and puppeteer tries to download another. So, probably, you should consider to update runner image for ubuntu 22.04

The second problem is the script does not wait for the google-chrome to be downloaded(see nodejs/node#22088 and according to the script works as expected - node exits before the await , that is a wrapper around a promise), returns.)

It can be workarounded with adding a callback that makes nodejs to wait for it

const puppeteer = require('puppeteer')

let READY = false // <==== exit condition

const runScrape = async () => {
  console.log('await puppeteer.launch()')
  const browser = await puppeteer.launch({executablePath: '/usr/bin/google-chrome'})
  
  console.log('await browser.newPage()')
  const page = await browser.newPage()
  
  console.log('await page.goto')
  await page.goto('https://koronavirus.gov.hu')
  
  console.log('the Node.Js script is launched succesfully')
  await browser.close()
  READY = true // <==== set exit condition
}


runScrape()

// now wait while condition is set
function wait () {
  if (!READY) {
        setTimeout(()=>{console.log('ready')}, 1000);
  }
};
wait();
console.log('end script')

And finally, when i tried to wait for the downloading of the recent google-chrome (i.e. omit {executablePath: '/usr/bin/google-chrome'}) i got pupper timeout, so there's another problem to download the google-chrome i can not resolve being not well known with pupper internals.

Does it help?

@theDavidBarton
Copy link
Author

theDavidBarton commented Dec 26, 2022

hi @dsame,

thank you very much for your extraordinary efforts on the issue. yes, with the information you provided I found out that puppeteer v5.3.0 gave a warning: warning puppeteer@5.5.0: < 18.1.0 is no longer supported during npm install and it seems it means Ubuntu 20.04 still handles this version while 22.04 has the above issue.

simply upgrading to puppeteer v18.1.0 solves my issue with ubuntu-latest image. https://github.com/Crocodiles-in-the-Basement/koronavirus.gov.hu-scraper/actions/runs/3782984220/jobs/6431168530

it was a project maintenance debt on my side, thanks @dsame and @igorboskovic3 for your time spent with the resolution.

I suppose the problem above caused the images has not most-recent version of google-chrome and puppeteer tries to download another. So, probably, you should consider to update runner image for ubuntu 22.04

I think this is not needed, as the issue resolves by upgrading project dependencies based on the npm warnings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report investigate Collect additional information, like space on disk, other tool incompatibilities etc. OS: Ubuntu
Projects
None yet
Development

No branches or pull requests

3 participants