Serverless-express: npm run win-local doesn't work

Created on 28 Jan 2017  路  7Comments  路  Source: vendia/serverless-express

This lib seems to use unix sockets for the proxy, which won't work on windows. I was able to get it to work by modifying the http request and server listen calls to use localhost + port.

bug help wanted

Most helpful comment

I just ran into this issue as well. Running node.js 6.10 on Windows 10 I got this error:

Error: listen EACCES /tmp/server0.sock

The offending line of code will only work on unix-like systems. I took a quick look at the relevant docs[1][2] and came up with a quick workaround that uses windows pipes instead of sockets if you are on windows.

function getSocketPath(socketPathSuffix) {
  if (/^win/.test(process.platform)) {
    const path = require('path')
    return path.join('\\\\?\\pipe', process.cwd(), `server${socketPathSuffix}`);
  }
  else {
    return `/tmp/server${socketPathSuffix}.sock`
  }
}
  1. https://nodejs.org/api/net.html#net_server_listen_path_backlog_callback
  2. https://nodejs.org/api/net.html#net_identifying_paths_for_ipc_connections

All 7 comments

Can you provide example and potentially PR?

The issue exists with the example project. When executing npm run win-local, node launches and then the process immediately exits without any output. It never successfully creates a server nor handles the sample event.

Agreed over here. Neither win-local or win-setup work for me. Attached is my log from win-local

2017-04-14T18_22_31_791Z-debug.log.txt
2017-04-14T18_22_31_891Z-debug.log.txt

I just ran into this issue as well. Running node.js 6.10 on Windows 10 I got this error:

Error: listen EACCES /tmp/server0.sock

The offending line of code will only work on unix-like systems. I took a quick look at the relevant docs[1][2] and came up with a quick workaround that uses windows pipes instead of sockets if you are on windows.

function getSocketPath(socketPathSuffix) {
  if (/^win/.test(process.platform)) {
    const path = require('path')
    return path.join('\\\\?\\pipe', process.cwd(), `server${socketPathSuffix}`);
  }
  else {
    return `/tmp/server${socketPathSuffix}.sock`
  }
}
  1. https://nodejs.org/api/net.html#net_server_listen_path_backlog_callback
  2. https://nodejs.org/api/net.html#net_identifying_paths_for_ipc_connections

@talawahtech I just updated the code on my local version, it works on Windows 10. Could you or someone else make a PR and add this to the project ?

I can look into it next week if no one has time to work on this.

Fixed by #100

Was this page helpful?
0 / 5 - 0 ratings

Related issues

muswain picture muswain  路  8Comments

damienwebdev picture damienwebdev  路  4Comments

brikis98 picture brikis98  路  9Comments

Vadorequest picture Vadorequest  路  3Comments

Muthuveerappanv picture Muthuveerappanv  路  6Comments