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

Gitlab CI timeout in "next lint" with Next.js 11.1.0 #28194

Closed
ateufel opened this issue Aug 17, 2021 · 6 comments · Fixed by #28299
Closed

Gitlab CI timeout in "next lint" with Next.js 11.1.0 #28194

ateufel opened this issue Aug 17, 2021 · 6 comments · Fixed by #28299
Labels
bug Issue was opened via the bug report template.

Comments

@ateufel
Copy link

ateufel commented Aug 17, 2021

What version of Next.js are you using?

11.1.0

What version of Node.js are you using?

14.x

What browser are you using?

Chrome

What operating system are you using?

Linux

How are you deploying your application?

Gitlab CI

Describe the Bug

I am using Gitlab CI to test and deploy a Next.js App, there is a Pipeline Stage for linting:

test:lint:
    stage: test
    dependencies:
        - prepare
    script:
        - yarn lint

It is pretty simple, the "prepare" Stage is bascially "yarn install" and works perfectly fine. Since Next.js 11.1.0, i get a timeout after 1h in the Gitlab Pipeline right after yarn lint:

$ yarn lint
info  - Loaded env from /builds/vetdoc/webapp/.env
✔ No ESLint warnings or errors
ERROR: Job failed: execution took longer than 1h0m0s seconds

The docker image is just a simple node 14 alpine image, and it does work perfectly fine with Next.js 11.0.1 (tried several times, it is always reproducable for me)

Expected Behavior

The Gitlab CI Pipeline works perfectly fine with Next.js 11.1.0+

To Reproduce

  • Use Gitlab CI with a Node.js 14 Alpine Image
  • Add a stage with "yarn lint" (which basically uses next lint)
@ateufel ateufel added the bug Issue was opened via the bug report template. label Aug 17, 2021
@rtritto
Copy link

rtritto commented Aug 17, 2021

Same problem here where next lint command doesn't close process after it is completed with No ESLint warnings or errors.
It was introduced from v11.0.2-canary.22 of Next.js.
It still persists with currently latest v11.1.1-canary.10.

@housseindjirdeh
Copy link
Collaborator

@ateufel @rtritto Would it be possible for you to share your .gitlab-ci.yml configuration? Couldn't reproduce it on the latest version of stable:

Screen Shot 2021-08-18 at 11 23 16 AM

It was introduced from v11.0.2-canary.22 of Next.js.

The only significant change that I noticed on v11.0.2-canary.22 was when I changed next lint to be an async function. Do you think that might be the reason? (does gitlab CI stall with async functions that have no return statement?)

@rtritto
Copy link

rtritto commented Aug 18, 2021

@housseindjirdeh thanks for answer.

After some checks, in my case, the problem of unclosed process of next lint is caused by a require('next-pwa') in next.config.js file.

Steps to reproduce

  1. yarn init -y
  2. yarn set version berry
  3. yarn add next react react-dom next-pwa
  4. yarn add -D eslint eslint-config-next
  5. Create file next.config.js
require('next-pwa')

module.exports = {}
  1. Create file .eslintrc.yml
extends:
  next
  1. Create folder pages
  2. yarn next lint

edit # 1:

The only significant change that I noticed on v11.0.2-canary.22 was when I changed next lint to be an async function. Do you think that might be the reason? (does gitlab CI stall with async functions that have no return statement?)

Yes, the problem should be generated adding async with this change:

  • ESLint: custom directories from next.config.js: #26401.

edit # 2:
Possible fix on file next-lint.ts:

...
  runLintCheck(
    baseDir,
    lintDirs,
    false,
    eslintOptions(args),
    reportErrorsOnly,
    maxWarnings,
    formatter
  )
    .then(async (lintResults) => {
...
      if (lintOutput) {
        console.log(lintOutput)
      } else {
        console.log(chalk.green('✔ No ESLint warnings or errors'))
      }
+     process.exit(0)
    })
    .catch((err) => {
      printAndExit(err.message)
    })
...

OR

...
  runLintCheck(
    baseDir,
    lintDirs,
    false,
    eslintOptions(args),
    reportErrorsOnly,
    maxWarnings,
    formatter
  )
    .then(async (lintResults) => {
...
      if (lintOutput) {
-       console.log(lintOutput)
+       printAndExit(lintOutput, 0)
      } else {
-       console.log(chalk.green('✔ No ESLint warnings or errors'))
+       printAndExit(chalk.green('✔ No ESLint warnings or errors'), 0)
      }
    })
    .catch((err) => {
      printAndExit(err.message)
    })
...

@housseindjirdeh
Copy link
Collaborator

@rtritto Thank you so much for the detailed reproduction steps and your thoughts :). I was able to reproduce it!

Yes, the problem should be generated adding async with this change:

Yep I was thinking it had to be that, and actually didn't even realize the next lint process wasn't exiting for successful outputs. Thanks for the suggestions, just put up #28299 to fix this.

@kodiakhq kodiakhq bot closed this as completed in #28299 Aug 19, 2021
kodiakhq bot pushed a commit that referenced this issue Aug 19, 2021
This PR ensures that `next lint` always exits after the process is complete. This fixes #28194.
@housseindjirdeh
Copy link
Collaborator

Thanks for logging this folks, fixed in v11.1.1-canary.13 🚀

@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants