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

verify http file server give strange results #13

Closed
yakticus opened this issue Sep 18, 2013 · 4 comments
Closed

verify http file server give strange results #13

yakticus opened this issue Sep 18, 2013 · 4 comments

Comments

@yakticus
Copy link

I haven't ruled out that this is a PEBKAC yet. This is the solution I have for HTTP file server:

var http = require('http')
var fs = require('fs')

if(process.argv.length < 3) {
  console.error('you forgot to give me a file')
  process.exit
}

var file = process.argv[2]

var server = http.createServer(function (request, response) {
  var stream = fs.createReadStream(file)
  stream.pipe(response)
})

server.listen(8000)

When I hit this in a browser (after passing in an ASCII file on the filesystem), it always returns consistent (and expected) results. When I use learnyounode verify, it always returns different (inconsistent) results that don't match expected.

Couple of examples:

$ learnyounode verify httpfileserver.js
ACTUAL:   "As cross as a cane toad no worries it'll be bizzo. Come a grouse bloody you little ripper swag. As cross as a bush bash my shazza got us some thingo."
EXPECTED: "We're going pot also mad as a struth. Lets get some slabs when he's got a massive grog. We're going sleepout how as cross as a cockie. Watch out for the ankle biter no dramas come a rotten. Watch out for the captain cook mate stands out like a piker."

Another one (expected is the same as above):

ACTUAL:   "You little ripper freo bloody as cross as a crook. As cross as a esky and as stands out like corker. Stands out like a chrissie how grab us a jillaroo. Mad as a prezzy to as cross as a slacker."
@rvagg
Copy link
Contributor

rvagg commented Sep 18, 2013

@julieonjava try this: killall node and then run the verify again. The fact that the EXPECTED is the same each time indicates that it's the same verification server still running, still reading the same file. Each time you verify or run a totally new file is created for you so it should be unique on each run. One problem with these server examples is that if you try and verify some broken code you can leave it with a node process running in the background. Something we'll need to sort out because it's come up a few times.

@rvagg
Copy link
Contributor

rvagg commented Sep 18, 2013

btw, your solution looks great so it's just a problem on the verification end, make sure you don't have a stray node process and you should pass.

@yakticus
Copy link
Author

Thanks. Issue resolved. I thought I had tried killall before, but this time it worked. Maybe it's worth adding a hint about this in the instructions?

@rvagg
Copy link
Contributor

rvagg commented Sep 18, 2013

yeah, although I think I need to work on making sure that child processes die properly by themselves so it's not a problem.

@rvagg rvagg closed this as completed Sep 18, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants