Skip to content

Commit

Permalink
Wait until server is really listening
Browse files Browse the repository at this point in the history
  • Loading branch information
uurien committed Jun 18, 2024
1 parent bb4e965 commit 70ff2f1
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions packages/datadog-plugin-next/test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,23 @@ describe('Plugin', function () {
})

server.once('error', done)
server.stdout.once('data', () => {
function waitForStarted (chunk) {
if (chunk.toString().includes(`port: ${port}`)) {
server.stdout.off('data', waitForStarted)
done()
}
}

server.stdout.on('data', waitForStarted)
// server.stdout.once('data', () => {
// first log outputted isn't always the server started log

Check failure on line 74 in packages/datadog-plugin-next/test/index.spec.js

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 10 spaces but found 12
// https://github.com/vercel/next.js/blob/v10.2.0/packages/next/next-server/server/config-utils.ts#L39

Check failure on line 75 in packages/datadog-plugin-next/test/index.spec.js

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 10 spaces but found 12
// these are webpack related logs that run during execution time and not build

Check failure on line 76 in packages/datadog-plugin-next/test/index.spec.js

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 10 spaces but found 12

// additionally, next.js sets timeouts in 10.x when displaying extra logs

Check failure on line 78 in packages/datadog-plugin-next/test/index.spec.js

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 10 spaces but found 12
// https://github.com/vercel/next.js/blob/v10.2.0/packages/next/server/next.ts#L132-L133

Check failure on line 79 in packages/datadog-plugin-next/test/index.spec.js

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 10 spaces but found 12
setTimeout(done, 700) // relatively high timeout chosen to be safe
})
// setTimeout(done, 700) // relatively high timeout chosen to be safe
// })
server.stderr.on('data', chunk => process.stderr.write(chunk))
server.stdout.on('data', chunk => process.stdout.write(chunk))
})
Expand Down

0 comments on commit 70ff2f1

Please sign in to comment.