Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't Work In Gulp 4 #45

Open
ghost opened this issue Jul 19, 2017 · 9 comments
Open

Doesn't Work In Gulp 4 #45

ghost opened this issue Jul 19, 2017 · 9 comments

Comments

@ghost
Copy link

ghost commented Jul 19, 2017

I am currently trying to get gulp-connect-php running on a gulp4.0 version. I have tried with my existing gulp file and with a standalone project, Neither to much joy.

[10:07:09] Using gulpfile C:\development\gulp4\gulpfile.js
[10:07:09] Starting 'default'...
[10:07:09] Starting 'connect-sync'...
[10:07:09] The following tasks did not complete: default, connect-sync
[10:07:09] Did you forget to signal async completion?

This tends to be the issue that appears with the following gulpfile.js:

var gulp = require('gulp'),
    connect = require('gulp-connect-php');
    
gulp.task('connect-sync', function() {
  connect.server({});
});

gulp.task('default', gulp.series('connect-sync'));

Is there any possibility of getting this working with the new gulp4.0?

@grmartin
Copy link
Collaborator

grmartin commented Jul 19, 2017

@KITSDominicWhite so the official line would be "Gulp4 has not been released in a final form", but I hate it when people respond like that... so I'll do the best I can to assist.

Gulp 4 has a bunch of breaking differences from Gulp 3 one of which is that tasks are supposed to return a promise or implement the 'done parameter callback pattern'. Failure to do so will cause the task to timeout with that warning if it is being held open by anything it invoked internally.

An example of the 'done parameter callback pattern' would be:

var gulp = require('gulp'),
    connect = require('gulp-connect-php');
    
gulp.task('connect-sync', function(done) {
  connect.server({});
  // never invoking done should hold this task in a 'running' state
  // Gulp4 checks the param count on the supplied function and
  // if >= 1 waits indefinitely until a done() call is invoked.
});

gulp.task('default', gulp.series('connect-sync'));

Now, if for some reason you need this to hold until you are ready for it to complete... the following should work (Linux/Mac):

var gulp = require('gulp'),
    connect = require('gulp-connect-php');
    
gulp.task('connect-sync', function(done) {
  console.log(`Invoking gulp-connect-php on PID: ${process.pid}.`);

  connect.server({});

  // https://nodejs.org/api/process.html#process_signal_events
  // NOTE:
  // SIGINT might also work, that is sent when you issue CTRL+C
  // However there is a chance Gulp reacts to it or hides it internally.
  process.once('SIGUSR2', function() {
    console.log("Got SIGUSR2, invoking callback.");
    connect.closeServer();
    done();
  });
});

gulp.task('default', gulp.series('connect-sync'));

Now if you issue a signal via the command line:

kill -SIGUSR2 PID

That should tell the task to terminate.

(All of this is speculative, but it is what i'd try).

@grmartin
Copy link
Collaborator

@KITSDominicWhite any luck?

@ghost
Copy link
Author

ghost commented Jul 25, 2017

Sorry @grmartin I went on holiday for a few days. I have given the first one a try with a few variants of my own, and unfortunately I haven't been able to get it working.

I am going to dig a little deeper into it and see if I can get some more information / figure it out :)

@grmartin
Copy link
Collaborator

@KITSDominicWhite No worries! If i can assist or if you get it working, please let me know.

@kristian
Copy link

+1 to this issue

@kirkbross
Copy link

+1

@DRSDavidSoft
Copy link

DRSDavidSoft commented Mar 28, 2019

I have gulp-connect-php + browserSync working perfectly fine
using Gulp 4.0.0 + PHP 7.3.2 on Windows 10.
PHP.exe for me is on %PATH%.

Does this issue only occur on Linux / macOS?

@kristian
Copy link

Worked for me on Windows, after putting the php executable on the PATH. It just gave me a hard time, as the error message when PHP is not installed was quite hard to understand. No issues on Gulp 4.0 though.

@suprim12
Copy link

it stopped working after requiring database connection (db.php)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants