Comments (10)
Neither me or Travis is seeing this. What Node and OS version are you on?
@brodkin Thoughts?
from grunt-php.
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.
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.
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.
👍
from grunt-php.
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.
@sindresorhus I'll look at this as soon as you merge #19 as to avoid merge conflicts down the road.
from grunt-php.
Merged ;)
from grunt-php.
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.
Closing as I can't reproduce. Make sure you're on the latest stable node version.
from grunt-php.
Related Issues (20)
- Add middleware options HOT 6
- watch livereload task works slow HOT 1
- Suppress loaded resources in shell? HOT 4
- KeepAlive: false HOT 1
- Problem running grunt-php in windows. HOT 1
- Here's how to setup this plugin with livereload HOT 1
- How can I specify which browser should be used with the 'open' parameter? HOT 7
- Couldn't find the PHP binary HOT 1
- hi can i use it with yeoman webapp generator?!! HOT 1
- Ability to add environment variables HOT 2
- Problem with router.php only when being ran from task HOT 6
- Directory not found HOT 9
- how can I set a variables in *.php HOT 3
- Build failing HOT 1
- mysqli class not found HOT 1
- how to: server config, .htaccess, 404 page file, etc. HOT 2
- Fatal error: Cannot set property 'build' of null HOT 1
- Checking if the grunt-php server is running HOT 1
- Is there a way to use HTTPS out of the box? HOT 1
- Rewrite rules HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grunt-php.