gulp-connect icon indicating copy to clipboard operation
gulp-connect copied to clipboard

Is there a callback function or promise for when connect.server starts?

Open BrianWalters opened this issue 7 years ago • 2 comments

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.

BrianWalters avatar Nov 21 '17 17:11 BrianWalters

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!

johnnynode avatar Jan 05 '18 14:01 johnnynode

You can provide the callback as the second argument to server: connect.server(options, callbackFn);

hya15 avatar Jul 28 '18 19:07 hya15