2016-11-15 4 views
0

gulpの簡単な監視で、gulp-connectを使用してすべてのjsファイルをリロードしていますが、そのうちの1つに変更がある場合、タスクが実行をasociated:gulp.watchでgulp-connectを実行した後にエラーが発生しました

[15:14:35] Starting 'livereload:js'... 
events.js:160 
     throw er; // Unhandled 'error' event 
    ^

Error: write after end 
    at ServerResponse.OutgoingMessage.write (_http_outgoing.js:439:15) 
    at ServerResponse.res.inject.res.write (C:\dev\test-livereload\node_modules\connect-livereload\index.js:115:37) 
    at ReadStream.ondata (_stream_readable.js:555:20) 
    at emitOne (events.js:96:13) 
    at ReadStream.emit (events.js:188:7) 
    at readableAddChunk (_stream_readable.js:176:18) 
    at ReadStream.Readable.push (_stream_readable.js:134:10) 
    at onread (fs.js:1984:12) 
    at FSReqWrap.wrapper [as oncomplete] (fs.js:681:17) 

ここでは、コードです:

gulp.task('livereload:js', function() { 
    return gulp.src([paths.APP_ROOT + '/**/*.js']) 
    //.pipe(wait(2000)) // if I add a small wait it doesn't crash as often 
    .pipe(connect.reload()); 
}); 

gulp.task('run-watch', function() { 
    gulp.watch([paths.APP_ROOT + '/**/*.js'], ['livereload:js']); 
}); 

私はSCSSファイルの変更をチェックし、それが正常に動作リロードする前に、それらをコンパイルする同様のタスクを持っています。

+0

エラーを再現できません。** whole ** gulpfile.jsを表示できますか? – aristotll

答えて

0

回避策が見つかりました。 gulp.watchの代わりにgulp-watchパッケージを使用してconnect.reload()を実行します。これはパイプで使用できます。

ファイルが準備される前にリロードをトリガしていた競合状態があったと思います。

関連する問題