diff --git a/lib/wait-on.js b/lib/wait-on.js index ea09ec1..402d3de 100644 --- a/lib/wait-on.js +++ b/lib/wait-on.js @@ -22,7 +22,7 @@ const PREFIX_RE = /^((https?-get|https?|tcp|socket|file):)(.+)$/; const HOST_PORT_RE = /^(([^:]*):)?(\d+)$/; const HTTP_GET_RE = /^https?-get:/; const HTTP_UNIX_RE = /^http:\/\/unix:([^:]+):([^:]+)$/; -const TIMEOUT_ERR_MSG = 'Timeout'; +const TIMEOUT_ERR_MSG = 'Timed out waiting for'; const WAIT_ON_SCHEMA = Joi.object({ resources: Joi.array().items(Joi.string().required()).required(), @@ -125,13 +125,15 @@ function waitOnImpl(opts, cbFunc) { let lastResourcesState = resources; // the last state we had recorded const timeoutError$ = - timeout !== Infinity ? timer(timeout).pipe(mergeMap(() => throwError(Error('Timeout')))) : NEVER; + timeout !== Infinity ? timer(timeout).pipe(mergeMap(() => { + const resourcesWaitingFor = determineRemainingResources(resources, lastResourcesState).join(', ') + return throwError(Error(`Timed out waiting for: ${resourcesWaitingFor}`)) + })) : NEVER; function cleanup(err) { if (err) { - if (err.message === TIMEOUT_ERR_MSG) { - const resourcesWaitingFor = determineRemainingResources(resources, lastResourcesState).join(', '); - log('wait-on(%s) timed out waiting for: %s; exiting with error', process.pid, resourcesWaitingFor); + if (err.message.startsWith(TIMEOUT_ERR_MSG)) { + log('wait-on(%s) %s; exiting with error', process.pid, err.message); } else { log('wait-on(%s) exiting with error', process.pid, err); }