Skip to content

Commit 5f2f7df

Browse files
committed
Increase server check timeout & log non-200 response code
1 parent 039cc2e commit 5f2f7df

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

cypress.config.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ const serverFlagPath = path.resolve(__dirname, 'serverStarted')
77
const payload = {
88
"query": "{ moduleConfigurations { module, config, controls { field, usage } } }"
99
}
10-
const timeout = 4 * 60 * 1000 // 4 minutes
11-
const interval = 10000 // Check every 10 seconds
10+
const timeoutMinutes = 10
11+
const retryIntervalSeconds = 15
1212

1313
function waitForServerToStart(url) {
1414
console.log('Waiting for API server to start...')
@@ -30,11 +30,13 @@ function waitForServerToStart(url) {
3030
}
3131
})
3232
.catch(error => {
33-
if (Date.now() - startTime >= timeout) {
34-
return reject(new Error('Timed out waiting for the server to start'))
33+
if (Date.now() - startTime >= timeoutMinutes * 60 * 1000) {
34+
return reject(
35+
new Error(`Timed out waiting for the server to start: ${error.message}`)
36+
)
3537
} else {
36-
console.log(`Retrying in ${interval / 1000} seconds...`)
37-
return setTimeout(checkServer, interval)
38+
console.log(`${error.message}. Retrying in ${retryIntervalSeconds} seconds...`)
39+
return setTimeout(checkServer, retryIntervalSeconds * 1000)
3840
}
3941
})
4042
}
@@ -50,7 +52,7 @@ module.exports = defineConfig({
5052
projectId: "q6gc25", // Cypress Cloud, needed for recording
5153
baseUrl: 'http://localhost',
5254
defaultCommandTimeout: 15000,
53-
taskTimeout: 300000,
55+
taskTimeout: timeoutMinutes * 60 * 1000 + 10,
5456
downloadsFolder: 'cypress/downloads',
5557
setupNodeEvents(on, config) {
5658
on('task', {
@@ -66,8 +68,9 @@ module.exports = defineConfig({
6668
return null
6769
})
6870
.catch(error => {
69-
console.error('Failed to start server:', error)
70-
return null
71+
console.error('Failed to start server:')
72+
console.error(error.stack);
73+
return reject(error);
7174
})
7275
},
7376
removeSetupFile() {

0 commit comments

Comments
 (0)