Skip to content

Commit 8becc26

Browse files
feat: log a warning if node process didn't listen
1 parent 05c5dc5 commit 8becc26

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

plugins/node/src/tasks/node.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { hookConsole, hookFork } from '@dotcom-tool-kit/logger'
1+
import { hookConsole, hookFork, styles } from '@dotcom-tool-kit/logger'
22
import { writeState } from '@dotcom-tool-kit/state'
33
import { Task, TaskRunContext } from '@dotcom-tool-kit/base'
44
import { DopplerEnvVars } from '@dotcom-tool-kit/doppler'
@@ -85,11 +85,19 @@ export default class Node extends Task<{ task: typeof NodeSchema }> {
8585
if (port) {
8686
const unhook = hookConsole(this.logger, 'wait-port')
8787
try {
88-
await waitPort({
88+
const { open } = await waitPort({
8989
host: 'localhost',
9090
port,
9191
timeout: this.options.portTimeout
9292
})
93+
94+
if (this.options.portTimeout && !open) {
95+
this.logger.warn(
96+
`Node process didn't listen on port ${styles.code(port)} within ${styles.code(
97+
this.options.portTimeout
98+
)}ms`
99+
)
100+
}
93101
} finally {
94102
unhook()
95103
}

0 commit comments

Comments
 (0)