gulp-connect
gulp-connect copied to clipboard
Is there a callback function or promise for when connect.server starts?
Currently using gulp-connect for a task like in the "Start and stop server" example. It works for my needs, but I can't figure out a way to programmatically know when the server has begun listening. Since connect.server seems to be asynchronous, my first few requests result in "Page crashed" errors from puppeteer. I am currently using a setTimeout, but that feels hacky.
middleware: function(connect, opt) {
console.log('opt');
console.log(opt);
return [];
}
I don't know really! But I found a clue here, when I log the "opt" argument, it turns out :
app:
{ [Function: app]
use: [Function],
handle: [Function],
listen: [Function],
domain: undefined,
_events: undefined,
_maxListeners: undefined,
setMaxListeners: [Function: setMaxListeners],
getMaxListeners: [Function: getMaxListeners],
emit: [Function: emit],
addListener: [Function: addListener],
on: [Function: addListener],
prependListener: [Function: prependListener],
once: [Function: once],
prependOnceListener: [Function: prependOnceListener],
removeListener: [Function: removeListener],
removeAllListeners: [Function: removeAllListeners],
listeners: [Function: listeners],
listenerCount: [Function: listenerCount],
eventNames: [Function: eventNames],
route: '/',
stack: []
}
Maybe one of the eventListeners can do a little help , I didn't figure it out yet!
You can provide the callback as the second argument to server
:
connect.server(options, callbackFn)
;