Timing out on nexus npm proxy with gradle on node plugin

We have a gradle with node plugin, these are the settings,

plugins {
	id 'java'
	id 'java-library'
	id "org.springframework.boot" version "2.7.15"
	id "com.github.node-gradle.node" version "3.5.1"
}

node {
    version = '22.15.0'
	distBaseUrl = 'https://nexus-server:8441/repository/npm-dist/'
    workDir = file("${project.projectDir}/.gradle/nodejs")
    npmWorkDir = file("${project.projectDir}/.gradle/npm")
    yarnWorkDir = file("${project.projectDir}/.gradle/yarn")
    nodeProjectDir = file("${project.projectDir}/src/main/web")
    download = true // ensure node is downloaded and ready to use
	npmInstallCommand = System.env['CI'] == "true" ? "ci" : "install"	
}



tasks.withType(com.github.gradle.node.npm.task.NpmTask).configureEach {
    environment.put("NODE_TLS_REJECT_UNAUTHORIZED", "0")
	environment.put('NPM_CONFIG_STRICT_SSL', 'false')
}

npmInstall.args = [
    '--registry', 'https://nexus-server:8441/repository/npm-proxy/',
    '--no-audit',
    '--no-fund',
    '--prefer-offline',
    '--fetch-retries=5',
    '--fetch-retry-maxtimeout=60000',
    '--network-concurrency=1',
    '--verbose'
]

task buildReactApp(type: NpmTask) {
	if (System.env['CI'] == "true" && // ensure node_modules not empty
		new File(file(project.node.npmWorkDir).getPath(),'/node_modules').list()) {
		timeout = Duration.ofMinutes(60) // in case node plugin stuck when missing modules
	} else {
		dependsOn npmInstall
	}

    args = ['run', 'build']
}

It’s timing out on the gitlab pipeline,

npm http fetch GET 200 https://nexus-server:8441/repository/npm-proxy/@ant-design/icons/-/icons-5.6.1.tgz 269171ms (cache miss)
npm http fetch GET 200 https://nexus-server:8441/repository/npm-proxy/@mui/material/-/material-5.17.1.tgz 269606ms (cache miss)
npm http fetch GET 200 https://nexus-server:8441/repository/npm-proxy/@ant-design/icons-svg/-/icons-svg-4.4.2.tgz 275746ms (cache miss)
npm http fetch GET 200 https://nexus-server:8441/repository/npm-proxy/@ant-design/icons/-/icons-4.8.3.tgz 346035ms (cache miss)
npm http fetch GET 200 https://nexus-server:8441/repository/npm-proxy/ace-builds/-/ace-builds-1.41.0.tgz 365262ms (cache miss)
WARNING: step_script could not run to completion because the timeout was exceeded. For more control over job and script timeouts see: https://docs.gitlab.com/ee/ci/runners/configure_runners.html#set-script-and-after_script-timeouts

Please help. Thanks.

Take a look at your Nexus logs to see if there are errors, or whether the requests even arrive at the server. I would not expect Nexus to need that long to cache.

1 Like

It give me this error and here’s the solution.

https://stackoverflow.com/questions/58888763/gitlab-build-stuck-on-creating-an-optimized-production-build