Skip to content
This repository has been archived by the owner on May 15, 2019. It is now read-only.

Emulator fails to start #77

Closed
EwanValentine opened this issue Mar 21, 2017 · 9 comments
Closed

Emulator fails to start #77

EwanValentine opened this issue Mar 21, 2017 · 9 comments

Comments

@EwanValentine
Copy link

Description

Emulator hangs on start

Steps to reproduce

On OSX, using node -v v6.9.1, run functions-emulator start.

I currently see Starting Google Cloud Functions Emulator... indefinitely.

Thanks!

@EwanValentine
Copy link
Author

I run sudo killall -9 node and restarted the emulator and it worked! Just a frozen process I suspect.

@EwanValentine
Copy link
Author

Re-opening this issue as I keep having to kill the node process because the emulator stops responding.

@jmdobry
Copy link
Contributor

jmdobry commented Mar 23, 2017

I'm going to need you to provide as many details as possible for me to be able to reproduce this locally. Node.js version, Emulator version, output of functions config list -j, code of the function you're deploying, contents of package.json, sequence of functions commands you're using to start, deploy, and call functions, etc.

@EwanValentine
Copy link
Author

EwanValentine commented Mar 23, 2017

$ functions-emulator config list -j

{
  "debug": false,
  "debugPort": 5858,
  "grpcHost": "localhost",
  "grpcPort": 8009,
  "inspect": false,
  "inspectPort": 9229,
  "logFile": "logs/cloud-functions-emulator.log",
  "region": "us-central1",
  "restHost": "localhost",
  "restPort": 8008,
  "service": "rest",
  "storage": "configstore",
  "supervisorHost": "localhost",
  "supervisorPort": 8010,
  "timeout": 60000,
  "useMocks": false,
  "verbose": false,
  "projectId": "euw-gcp-k8s-001"
}

Node -v => v6.9.1

package.json

{
  "name": "channel-site-frame",
  "version": "1.1.0",
  "description": "",
  "main": "build.js",
  "dependencies": {
    "ajv": "^3.4.0",
    "babel-core": "^6.17.0",
    "babel-preset-es2015": "^6.16.0",
    "babel-preset-react": "^6.16.0",
    "babel-preset-stage-2": "^6.17.0",
    "babelify": "7.3.0",
    "browserify": "13.1.0",
    "chai": "^3.5.0",
    "consolidate": "^0.13.1",
    "es6-promise": "^3.1.2",
    "eslint": "^3.7.1",
    "fbjs": "^0.8.6",
    "fs": "0.0.2",
    "fs-extra": "^0.30.0",
    "fs-walk": "0.0.1",
    "gulp": "^3.9.0",
    "gulp-autoprefixer": "^3.1.0",
    "gulp-browserify": "^0.5.1",
    "gulp-clean": "^0.3.1",
    "gulp-css-base64": "^1.3.4",
    "gulp-cssnano": "^2.1.1",
    "gulp-eslint": "^3.0.1",
    "gulp-front-matter": "^1.2.3",
    "gulp-gzip": "^1.2.0",
    "gulp-htmlmin": "^1.3.0",
    "gulp-htmltidy": "^0.2.2",
    "gulp-imagemin": "^2.4.0",
    "gulp-inject": "^3.0.0",
    "gulp-inline-image-html": "^0.2.1",
    "gulp-inline-source": "^2.1.0",
    "gulp-minify": "0.0.5",
    "gulp-minify-css": "^1.2.3",
    "gulp-rename": "^1.2.2",
    "gulp-rev": "^7.0.0",
    "gulp-rev-replace": "^0.4.3",
    "gulp-run-sequence": "^0.3.2",
    "gulp-sass": "^2.2.0",
    "gulp-sass-lint": "^1.2.0",
    "gulp-serve": "^1.2.0",
    "gulp-sourcemaps": "^1.6.0",
    "gulp-style-inject": "0.0.3",
    "gulp-svg-symbols": "^2.0.0",
    "gulp-uglify": "^1.5.3",
    "gulp-util": "^3.0.6",
    "gulpsmith": "^0.5.5",
    "handlebars": "^4.0.2",
    "harmonize": "^1.4.4",
    "imagemin-pngquant": "^4.2.0",
    "imagemin-svgo": "^4.2.0",
    "isomorphic-fetch": "^2.2.1",
    "lodash.assign": "^3.2.0",
    "lodash.escape": "^4.0.1",
    "metalsmith": "^2.0.1",
    "metalsmith-changed": "^0.2.0",
    "metalsmith-excerpts": "^1.0.0",
    "metalsmith-fingerprint": "^1.0.3",
    "metalsmith-layouts": "^1.6.4",
    "metalsmith-markdown": "^0.2.1",
    "metalsmith-partial": "^0.1.0",
    "metalsmith-permalinks": "^0.4.0",
    "metalsmith-publish": "^0.1.3",
    "metalsmith-register-helpers": "^0.1.2",
    "metalsmith-serve": "0.0.4",
    "mocha": "^2.5.3",
    "moment": "^2.12.0",
    "node-promise": "^0.5.12",
    "node-rest-client": "^1.5.1",
    "raven": "^0.11.0",
    "react": "^0.14.7",
    "require-dir": "0.3.0",
    "shrinkwrap": "^0.4.0",
    "sinon": "^1.17.6",
    "through2": "^2.0.1",
    "vinyl-buffer": "^1.0.0",
    "vinyl-source-stream": "^1.1.0",
    "yargs": "^3.32.0"
  },
  "scripts": {
    "test": "./node_modules/.bin/mocha ./src/tests/**; echo ''",
    "lint-js": "./node_modules/.bin/eslint --fix ./src; echo ''",
    "lint-scss": "./node_modules/.bin/sass-lint -c './node_modules/@theladbiblegroup/scss-linter/.scsslint.yaml'  './src/scss/**/*.scss' -v -q; echo ''",
    "fractal": "gulp fractal && gulp serve"
  },
  "author": "Jason Brown",
  "license": "ISC",
  "devDependencies": {
    "@frctl/consolidate": "^1.0.1",
    "@frctl/fractal": "^1.0.11",
    "browserify": "^13.3.0",
    "gulp-babel": "^6.1.2",
    "gulp-browserify": "^0.5.1",
    "gulp-string-replace": "^0.4.0",
    "through2": "^2.0.3"
  }
}

My cloud function code... (some of this is hacky as we're trying to wrap some static site build functions which are in gulp). But it does work. The problems arise when we attempt to re-deploy a function to the emulator etc

/**
 * Cloud functions
 *
 * This is the Google Cloud Functions file
 * for building the site within GC.
 *
 * @author    Ewan Valentine <ewan@theladbible.com>
 * @copyright LADbible Group - 2017
 */
const gulp = require('gulp');
const yargs = require('yargs');
require('./gulpfile.js');

/**
 * generateContentMatter
 *
 * @param {Event} event
 * @param {func} callback
 */
exports.generateContentMatter = function generateContentMatter(req, res) {
  const { id } = req.body
  return Promise.resolve() 
    .then(() => {
      if (req.method !== 'POST') {
        const err = new Error('Expecting a POST request?')
        err.code  = 405
        throw err
      }
      if (gulp.tasks['css']) {
        gulp.start('css', () => {
          console.log('Finished CSS.')
          return true
        });
      }
    })
    .then(() => {
      if (gulp.tasks['build-resource']) {
        yargs.default('--id', id)
        gulp.start('build-resource', () => {
          console.log('Finished!')
          res.send('Done m9').end()
        })
      }
    })
    .catch(err => {
      res.status(err.code).send(`Shit: ${err.message}.`);
    })
}

Emulator version, I did npm uninstall and installed again just now, so it'll be the very latest.

@jmdobry
Copy link
Contributor

jmdobry commented Mar 23, 2017

What version of the Emulator do you have installed?

@EwanValentine
Copy link
Author

1.0.0-alpha.15

@gerhardcit
Copy link

I have similar problems with killing the process.

If an error occurs in a function I get this message:

2017-04-12T20:29:52.312Z - error: Error: socket hang up
    at createHangUpError (_http_client.js:302:15)
    at Socket.socketOnEnd (_http_client.js:394:23)
    at emitNone (events.js:91:20)
    at Socket.emit (events.js:186:7)
    at endReadableNT (_stream_readable.js:974:12)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)

After that, functions kill does not work.
and I end up with a orphan process which is only killed with kill -9

simply deploy a function like this

exports.helloWim = functions.https.onRequest((request, response) => {
    cnt++;
    response.send("Hello from WIM!");
});

and call it. when the error appears, the emulator is in nowhere land

@jmdobry
Copy link
Contributor

jmdobry commented Apr 12, 2017

I'll be publishing another version soon that will hopefully solve your issue.

@jmdobry
Copy link
Contributor

jmdobry commented Apr 13, 2017

I released 1.0.0-alpha.16, can you see if it works better for you?

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

No branches or pull requests

3 participants