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

file remove itself #3805

Closed
bgbruno opened this issue Nov 12, 2015 · 7 comments
Closed

file remove itself #3805

bgbruno opened this issue Nov 12, 2015 · 7 comments
Labels
macos Issues and PRs related to the macOS platform / OSX. net Issues and PRs related to the net subsystem.

Comments

@bgbruno
Copy link

bgbruno commented Nov 12, 2015

Hello,

if I run this code on LINUX ends only with error and that is OK.
BUT if I run it on OSX it ends with error and REMOVE SCRIPT without no recovery. 😃

var http = require('http');

var server_ipAddr = '0.0.0.0';
var server_port = process.argv[1];

var server_http = http.createServer(function(req, res) {

  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello\n');

}).listen(server_port, server_ipAddr);

console.log('Server running at http://' + server_ipAddr + ':' + server_port);
$ node /Users/bruno/Downloads/script.js
Server running at http://0.0.0.0:/Users/bruno/Downloads/script.js
events.js:85
      throw er; // Unhandled 'error' event
            ^
Error: listen EADDRINUSE
    at exports._errnoException (util.js:746:11)
    at Server._listen2 (net.js:1112:19)
    at listen (net.js:1155:10)
    at Server.listen (net.js:1234:5)
    at Object.<anonymous> (/Users/bruno/Downloads/x:11:4)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)

refs

  • MAC OSX El Capitan 10.11.1 (15B42) + node v0.12.1
  • Linux Ubuntu 14.04.3 LTS (GNU/Linux 3.13.0-32-generic x86_64) + node v0.10.25
@evanlucas
Copy link
Contributor

process.argv[1] is the resolved filename of the first argument passed to node

@MylesBorins
Copy link
Contributor

MylesBorins commented Nov 12, 2015 via email

@evanlucas
Copy link
Contributor

It looks like it is starting a server using a unix socket at the path of the file you are running.

@mscdex mscdex added net Issues and PRs related to the net subsystem. macos Issues and PRs related to the macOS platform / OSX. labels Nov 12, 2015
@cjihrig
Copy link
Contributor

cjihrig commented Nov 12, 2015

Yes, verified what @evanlucas said. Change to process.argv[2] in your port calculation.

@cjihrig cjihrig closed this as completed Nov 12, 2015
@bgbruno
Copy link
Author

bgbruno commented Nov 12, 2015

I know @cjihrig - I have reported a BUG, because nodejs react differently on OSX and LINUX!

And I think if something can remove my script file without my permission that is NOT OK. 😝

Q @cjihrig my understanding for the future my efforts to reporting - why you CLOSE it?

@cjihrig
Copy link
Contributor

cjihrig commented Nov 12, 2015

I'm not 100% sure I would call this behavior a bug, as you're using the APIs incorrectly. The script file being deleted is unfortunate, but this seems to have been corrected in newer versions of Node (I ran on 0.12.1 and the file was removed, but it was not using master).

@bgbruno
Copy link
Author

bgbruno commented Nov 13, 2015

Thank you @cjihrig for your explanation.
I downloaded "OS X (x64) v5.0.0 Stable" and there it is OK. 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
macos Issues and PRs related to the macOS platform / OSX. net Issues and PRs related to the net subsystem.
Projects
None yet
Development

No branches or pull requests

5 participants