awesome-fc/webserverless

ENAMETOOLONG prox 监听异常

Opened this issue · 5 comments

ytfei commented

开发环境:Mac, Nodejs10

异常栈:

➜  demo-express git:(master) ✗ fun local start
using template: .fun/build/artifacts/template.yml
HttpTrigger httpTrigger of demo-express-service/demo-express was registered
	url: http://localhost:8000/2016-08-15/proxy/demo-express-service/demo-express
	methods: [ 'POST', 'GET' ]
	authType: ANONYMOUS


function compute app listening on port 8000!

skip pulling image aliyunfc/runtime-nodejs10:1.7.7...
FC Invoke Start RequestId: 33d7b103-34eb-42a5-a33c-c6731d34de38
load code for handler:index.handler
2020-01-19T08:41:52.736Z 33d7b103-34eb-42a5-a33c-c6731d34de38 [error] (node:20) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
2020-01-19T08:41:52.737Z 33d7b103-34eb-42a5-a33c-c6731d34de38 [verbose] ERROR: server error
2020-01-19T08:41:52.745Z 33d7b103-34eb-42a5-a33c-c6731d34de38 [error] { Error: listen ENAMETOOLONG: name too long /tmp/server-s73s90uqq8.sock
    at setupListenHandle (net.js:1253:19)
    at listenInCluster (net.js:1318:12)
    at Server.listen (net.js:1416:5)
    at ./node_modules/@webserverless/fc-express/lib/server.js.Server.startServer (/code/index.js:531:31)
    at ./node_modules/@webserverless/fc-express/lib/abstract-proxy.js.AbstractProxy.handle (/code/index.js:122:25)
    at ./node_modules/@webserverless/fc-express/lib/server.js.Server.httpProxy (/code/index.js:528:31)
    at ./src/index.js.module.exports.handler (/code/index.js:20622:10)
  code: 'ENAMETOOLONG',
  errno: 'ENAMETOOLONG',
  syscall: 'listen',
  address: '/tmp/server-s73s90uqq8.sock',
  port: -1 }

看代码里面主要是:

    getSocketPath() {
        /* istanbul ignore if */ /* only running tests on Linux; Window support is for local dev only */
        if (/^win/.test(process.platform)) {
            const path = require('path');
            return path.join('\\\\?\\pipe', process.cwd(), `server-${this.socketPathSuffix}`);
        } else {
            return `/tmp/server-${this.socketPathSuffix}.sock`;
        }
    }

官方文件说明这个长度是:It gets truncated to sizeof(sockaddr_un.sun_path) - 1, which varies on different operating system between 91 and 107 bytes. Identifying paths for IPC connections

我使用的是 阿里云的 fun 命令,不晓得 docker 是在什么环境下执行,请问如何才能查看查看这个具体的长度?

另外,这里文件长度变小一点,或者直接监听端口有没有问题? 刚开始用Node,基础问题了解不多

同样的问题,你解决了吗

ytfei commented

没有解决。使用 unix file 做通信就有这个问题。我改了代码,用 端口通信就正常。

用了这个包装所有的服务响应时间都增加了大概300ms左右,有知道是为什么吗,官方给的例子也是,本地最快响应也要300ms左右,去掉这个几ms就响应了

ytfei commented

你可以正常运行么?

已经解决