Coder Social home page Coder Social logo

Comments (10)

sindresorhus avatar sindresorhus commented on July 19, 2024

Neither me or Travis is seeing this. What Node and OS version are you on?

@brodkin Thoughts?

from grunt-php.

brodkin avatar brodkin commented on July 19, 2024

I would need to dig into it, but we're not currently testing for every error code under the sun. There also seems to be no documentation as to what error codes NPM interprets as errors.

All that said we could make the code a bit more modular and write unit tests that verify functionality for a wider variety of status codes. It would not be necessary to run a server for each status code. Instead we could create an endpoint that would generate any code by passing a query var and just test that portion of the code.

from grunt-php.

jelhan avatar jelhan commented on July 19, 2024

I am using grunt-php 1.0.1, php 5.5.9 and node.js 0.10.25 on Ubuntu 14.04 LTS. Bug occurs when there is no index.html / index.php in grunt-php base directory. Server is reporting a 404 error. node js is treating this one as HPE_INVALID_CONSTANT.

I created a very simple setup to reproduce the error:

Gruntfile.js

module.exports = function(grunt) {
require('load-grunt-tasks')(grunt); // npm install --save-dev load-grunt-tasks

grunt.initConfig({
    php: {
        dist: {
            options: {
                port: 8001,
                keepalive: true
            }
        }
    }
});

grunt.registerTask('default', ['php']);
}

package.json

{
  "name": "test",
  "version": "0.0.0",
  "description": "",
  "main": "index.js",
  "dependencies": {
    "grunt-php": "~1.0.1",
    "load-grunt-tasks": "~0.6.0"
  },
  "devDependencies": {
    "grunt": "~0.4.5"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "BSD-2-Clause"
}

Output:

$ grunt
Running "php:dist" (php) task
PHP 5.5.9-1ubuntu4.4 Development Server started at Mon Sep 29 11:41:53 2014
Listening on http://127.0.0.1:8001
Document root is /home/bla/tmp/test
Press Ctrl-C to quit.
[Mon Sep 29 11:41:53 2014] 127.0.0.1:51072 [404]: / - No such file or directory
[Mon Sep 29 11:41:53 2014] 127.0.0.1:51073 [404]: / - No such file or directory
[Mon Sep 29 11:41:53 2014] 127.0.0.1:51074 [404]: / - No such file or directory
[Mon Sep 29 11:41:53 2014] 127.0.0.1:51075 [404]: / - No such file or directory
[Mon Sep 29 11:41:53 2014] 127.0.0.1:51076 [404]: / - No such file or directory
[Mon Sep 29 11:41:53 2014] 127.0.0.1:51077 [404]: / - No such file or directory
[Mon Sep 29 11:41:53 2014] 127.0.0.1:51078 [404]: / - No such file or directory
[Mon Sep 29 11:41:53 2014] 127.0.0.1:51079 [404]: / - No such file or directory
[Mon Sep 29 11:41:53 2014] 127.0.0.1:51080 [404]: / - No such file or directory
[Mon Sep 29 11:41:53 2014] 127.0.0.1:51081 [404]: / - No such file or directory
[Mon Sep 29 11:41:53 2014] 127.0.0.1:51082 [404]: / - No such file or directory
[Mon Sep 29 11:41:53 2014] 127.0.0.1:51083 [404]: / - No such file or directory
[Mon Sep 29 11:41:53 2014] 127.0.0.1:51084 [404]: / - No such file or directory
[Mon Sep 29 11:41:53 2014] 127.0.0.1:51085 [404]: / - No such file or directory
[Mon Sep 29 11:41:54 2014] 127.0.0.1:51086 [404]: / - No such file or directory
[Mon Sep 29 11:41:54 2014] 127.0.0.1:51087 [404]: / - No such file or directory
[Mon Sep 29 11:41:54 2014] 127.0.0.1:51088 [404]: / - No such file or directory
[Mon Sep 29 11:41:54 2014] 127.0.0.1:51089 [404]: / - No such file or directory
[Mon Sep 29 11:41:54 2014] 127.0.0.1:51090 [404]: / - No such file or directory
[Mon Sep 29 11:41:54 2014] 127.0.0.1:51091 [404]: / - No such file or directory
[Mon Sep 29 11:41:54 2014] 127.0.0.1:51092 [404]: / - No such file or directory

If I add an console.log(err); to .on('error', function(err){}); in checkServer function I got this Output:

[Mon Sep 29 11:46:20 2014] 127.0.0.1:51096 [404]: / - No such file or directory
{ [Error: Parse Error] bytesParsed: 128, code: 'HPE_INVALID_CONSTANT' }

HTTP header reported by php built-in web server looks got for me:

$ curl -s -D - http://localhost:8001/ -o /dev/null
HTTP/1.1 404 Not Found
Host: localhost:8001
Connection: close
Content-Type: text/html; charset=UTF-8
Content-Length: 533

Versions of node.js packages:

$ npm list
[email protected] /home/bla/tmp/test
├─┬ [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ ├─┬ [email protected]
│ │ │ ├── [email protected]
│ │ │ └─┬ [email protected]
│ │ │   ├── [email protected]
│ │ │   └── [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ ├─┬ [email protected]
│ │ │ ├── [email protected]
│ │ │ └── [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ └── [email protected]
├─┬ [email protected]
│ ├─┬ [email protected]
│ │ ├─┬ [email protected]
│ │ │ └─┬ [email protected]
│ │ │   ├── [email protected]
│ │ │   ├── [email protected]
│ │ │   └── [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ └── [email protected]
└─┬ [email protected]
  ├─┬ [email protected]
  │ ├─┬ [email protected]
  │ │ ├── [email protected]
  │ │ └─┬ [email protected]
  │ │   ├── [email protected]
  │ │   └── [email protected]
  │ └── [email protected]
  └─┬ [email protected]
    ├── [email protected]
    ├─┬ [email protected]
    │ └── [email protected]
    └─┬ [email protected]
      ├── [email protected]
      └── [email protected]

Tested with node.js 0.10.32 due to nvm and node-grunt-version and same problem there.

from grunt-php.

brodkin avatar brodkin commented on July 19, 2024

I haven't looked into this issue in depth, but rather than spending hours manually testing for the issue let's just break out the two anonymous functions from the HTTP callbacks into a single named function that will check the status code returned and throw an error if the total number of tries is exceeded. As long as we treat errors and responses equally we don't have to worry about how Node interprets HTTP responses now or in the future.

from grunt-php.

sindresorhus avatar sindresorhus commented on July 19, 2024

👍

from grunt-php.

jelhan avatar jelhan commented on July 19, 2024

I'm not sure if this will fix the issue since node.js has a parse error on HTTP response returned by phpbuiltin webserver. We won't get a valid HTTP status code to check - atleast not in res.statusCode variable. If I got it right HPE_INVALID_CONSTANT error returned by node.js means that for node.js the whole HTTP response is invalid and so it isn't parsed.

from grunt-php.

brodkin avatar brodkin commented on July 19, 2024

@sindresorhus I'll look at this as soon as you merge #19 as to avoid merge conflicts down the road.

from grunt-php.

sindresorhus avatar sindresorhus commented on July 19, 2024

Merged ;)

from grunt-php.

brodkin avatar brodkin commented on July 19, 2024

Take a look at #44. The build passed with tests being added for both 400 and 404 errors. This must be a dependency issue. :(

from grunt-php.

sindresorhus avatar sindresorhus commented on July 19, 2024

Closing as I can't reproduce. Make sure you're on the latest stable node version.

from grunt-php.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.